ObjFW  Diff

Differences From Artifact [00ea092795]:

To Artifact [3b876afaf6]:


19
20
21
22
23
24
25

26
27
28
29
30
31
32

#ifndef OF_HAVE_SOCKETS
# error No sockets available!
#endif

OF_ASSUME_NONNULL_BEGIN


@class OFHTTPRequest;
@class OFHTTPResponse;
@class OFHTTPServer;
@class OFStream;
@class OFTCPSocket;

/*!







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#ifndef OF_HAVE_SOCKETS
# error No sockets available!
#endif

OF_ASSUME_NONNULL_BEGIN

@class OFArray;
@class OFHTTPRequest;
@class OFHTTPResponse;
@class OFHTTPServer;
@class OFStream;
@class OFTCPSocket;

/*!
95
96
97
98
99
100
101




102
103
104
105



106
107
108
109
110



111
112
113
114
115



116
117
118
119
120



121
122
123
124
125



126
127
128
129
130
131
132
133



134
135
136
137
138
139
140
141
142















143
144
145
146
147
148
149
	uint16_t _port;
	bool _usesTLS;
	OFString *_Nullable _certificateFile, *_Nullable _privateKeyFile;
	const char *_Nullable _privateKeyPassphrase;
	id <OFHTTPServerDelegate> _Nullable _delegate;
	OFString *_Nullable _name;
	OF_KINDOF(OFTCPSocket *) _Nullable _listeningSocket;




}

/*!
 * @brief The host on which the HTTP server will listen.



 */
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *host;

/*!
 * @brief The port on which the HTTP server will listen.



 */
@property (nonatomic) uint16_t port;

/*!
 * @brief Whether the HTTP server uses TLS.



 */
@property (nonatomic) bool usesTLS;

/*!
 * @brief The path to the X.509 certificate file to use for TLS.



 */
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *certificateFile;

/*!
 * @brief The path to the PKCS#8 private key file to use for TLS.



 */
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *privateKeyFile;

/*!
 * @brief The passphrase to decrypt the PKCS#8 private key file for TLS.
 *
 * @warning You have to ensure that this is in secure memory protected from
 *	    swapping! This is also the reason why this is not an OFString.



 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    const char *privateKeyPassphrase;

/*!
 * @brief The delegate for the HTTP server.
 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    id <OFHTTPServerDelegate> delegate;
















/*!
 * @brief The server name the server presents to clients.
 *
 * Setting it to `nil` means no `Server` header will be sent, unless one is
 * specified in the response headers.
 */







>
>
>
>




>
>
>





>
>
>





>
>
>





>
>
>





>
>
>








>
>
>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	uint16_t _port;
	bool _usesTLS;
	OFString *_Nullable _certificateFile, *_Nullable _privateKeyFile;
	const char *_Nullable _privateKeyPassphrase;
	id <OFHTTPServerDelegate> _Nullable _delegate;
	OFString *_Nullable _name;
	OF_KINDOF(OFTCPSocket *) _Nullable _listeningSocket;
#ifdef OF_HAVE_THREADS
	size_t _numberOfThreads, _nextThreadIndex;
	OFArray *_threadPool;
#endif
}

/*!
 * @brief The host on which the HTTP server will listen.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *host;

/*!
 * @brief The port on which the HTTP server will listen.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property (nonatomic) uint16_t port;

/*!
 * @brief Whether the HTTP server uses TLS.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property (nonatomic) bool usesTLS;

/*!
 * @brief The path to the X.509 certificate file to use for TLS.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *certificateFile;

/*!
 * @brief The path to the PKCS#8 private key file to use for TLS.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *privateKeyFile;

/*!
 * @brief The passphrase to decrypt the PKCS#8 private key file for TLS.
 *
 * @warning You have to ensure that this is in secure memory protected from
 *	    swapping! This is also the reason why this is not an OFString.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    const char *privateKeyPassphrase;

/*!
 * @brief The delegate for the HTTP server.
 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    id <OFHTTPServerDelegate> delegate;

#ifdef OF_HAVE_THREADS
/*!
 * @brief The number of threads the OFHTTPServer should use.
 *
 * If this is larger than 1 (the default), one thread will be used to accept
 * incoming connections and all others will be used to handle connections.
 *
 * For maximum CPU utilization, set this to `[OFSystemInfo numberOfCPUs] + 1`.
 *
 * Setting this after @ref start has been called raises an
 * @ref OFAlreadyConnectedException.
 */
@property (nonatomic) size_t numberOfThreads;
#endif

/*!
 * @brief The server name the server presents to clients.
 *
 * Setting it to `nil` means no `Server` header will be sent, unless one is
 * specified in the response headers.
 */