ObjFW  Diff

Differences From Artifact [8ee31cc729]:

  • File src/OFHTTPServer.h — part of check-in [0a73af49f0] at 2017-04-30 13:35:16 on branch trunk — Use nonatomic for properties and clean up

    This changes retaining behavior, meaning properties are not returned
    retained and autoreleased anymore, so a property returned from a getter
    now needs to be manually retained and autoreleased before calling the
    setter. However, this is rarely the case and not using atomic improves
    performance. (user: js, size: 4140) [annotate] [blame] [check-ins using]

To Artifact [7497041027]:


38
39
40
41
42
43
44
45
46
47



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81




82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
38
39
40
41
42
43
44



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77




78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108







-
-
-
+
+
+













-
-
+
+















-
-
-
-
+
+
+
+



















-
+







 * @brief This method is called when the HTTP server received a request from a
 *	  client.
 *
 * @param server The HTTP server which received the request
 * @param request The request the HTTP server received
 * @param response The response the server will send to the client
 */
-      (void)server: (OFHTTPServer*)server
  didReceiveRequest: (OFHTTPRequest*)request
	   response: (OFHTTPResponse*)response;
-      (void)server: (OFHTTPServer *)server
  didReceiveRequest: (OFHTTPRequest *)request
	   response: (OFHTTPResponse *)response;

@optional
/*!
 * @brief This method is called when the HTTP server's listening socket
 *	  encountered an exception.
 *
 * @param server The HTTP server which encountered an exception
 * @param exception The exception which occurred on the HTTP server's listening
 *		    socket
 * @return Whether to continue listening. If you return false, existing
 *	   connections will still be handled and you can start accepting new
 *	   connections again by calling @ref OFHTTPServer::start again.
 */
-			  (bool)server: (OFHTTPServer*)server
  didReceiveExceptionOnListeningSocket: (OFException*)exception;
-			  (bool)server: (OFHTTPServer *)server
  didReceiveExceptionOnListeningSocket: (OFException *)exception;

/*!
 * @brief This method is called when a client socket encountered an exception.
 *
 * This can happen when the OFHTTPServer tries to properly close the
 * connection. If no headers have been sent yet, it will send headers, and if
 * chunked transfer encoding was used, it will send a chunk of size 0. However,
 * if the other end already closed the connection before that, this will raise
 * an exception.
 *
 * @param server The HTTP server which encountered an exception
 * @param response The response for which the exception occurred
 * @param request The request for the response for which the exception occurred
 * @param exception The exception which occurred
 */
-		    (void)server: (OFHTTPServer*)server
  didReceiveExceptionForResponse: (OFHTTPResponse*)response
			 request: (OFHTTPRequest*)request
		       exception: (OFException*)exception;
-		    (void)server: (OFHTTPServer *)server
  didReceiveExceptionForResponse: (OFHTTPResponse *)response
			 request: (OFHTTPRequest *)request
		       exception: (OFException *)exception;
@end

/*!
 * @class OFHTTPServer OFHTTPServer.h ObjFW/OFHTTPServer.h
 *
 * @brief A class for creating a simple HTTP server inside of applications.
 */
@interface OFHTTPServer: OFObject
{
	OFString *_host;
	uint16_t _port;
	id <OFHTTPServerDelegate> _delegate;
	OFString *_name;
	OFTCPSocket *_listeningSocket;
}

/*!
 * The host on which the HTTP server will listen.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString* host;
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *host;

/*!
 * The port on which the HTTP server will listen.
 */
@property uint16_t port;

/*!