Differences From Artifact [e2c16ad886]:
- File
src/OFHTTPServer.m
— part of check-in
[6b4d138cc3]
at
2016-01-05 14:55:47
on branch trunk
— OFHTTPServer: Allow setting name to nil
Setting it to nil means no Server header is sent. (user: js, size: 15936) [annotate] [blame] [check-ins using]
To Artifact [eb56a06a9a]:
- File src/OFHTTPServer.m — part of check-in [3acdce88f5] at 2016-03-20 15:24:08 on branch trunk — OFHTTPServer: Delegate for client socket exception (user: js, size: 16459) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
170 171 172 173 174 175 176 177 178 179 180 | freeWhenDone: true]; } @interface OFHTTPServerResponse: OFHTTPResponse { OFTCPSocket *_socket; OFHTTPServer *_server; bool _chunked, _headersSent; } - initWithSocket: (OFTCPSocket*)socket | > | > > > > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | freeWhenDone: true]; } @interface OFHTTPServerResponse: OFHTTPResponse { OFTCPSocket *_socket; OFHTTPServer *_server; OFHTTPRequest *_request; bool _chunked, _headersSent; } - initWithSocket: (OFTCPSocket*)socket server: (OFHTTPServer*)server request: (OFHTTPRequest*)request; @end @implementation OFHTTPServerResponse - initWithSocket: (OFTCPSocket*)socket server: (OFHTTPServer*)server request: (OFHTTPRequest*)request { self = [super init]; _statusCode = 500; _socket = [socket retain]; _server = [server retain]; _request = [request retain]; return self; } - (void)dealloc { if (_socket != nil) [self close]; /* includes [_socket release] */ [_server release]; [_request release]; [super dealloc]; } - (void)OF_sendHeaders { void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
276 277 278 279 280 281 282 | } - (void)close { if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; | > | | | | | > > > > > > > > > > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | } - (void)close { if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { if (!_headersSent) [self OF_sendHeaders]; if (_chunked) [_socket writeBuffer: "0\r\n\r\n" length: 5]; } @catch (OFWriteFailedException *e) { id <OFHTTPServerDelegate> delegate = [_server delegate]; if ([delegate respondsToSelector: @selector(server: didReceiveExceptionForResponse:request:exception:)]) [delegate server: _server didReceiveExceptionForResponse: self request: _request exception: e]; } [_socket release]; _socket = nil; } - (int)fileDescriptorForWriting { |
︙ | ︙ | |||
646 647 648 649 650 651 652 | (of_http_request_protocol_version_t){ 1, _HTTPMinorVersion }]; [request setHeaders: _headers]; [request setBody: _body]; [request setRemoteAddress: [_socket remoteAddress]]; response = [[[OFHTTPServerResponse alloc] initWithSocket: _socket | | > | 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | (of_http_request_protocol_version_t){ 1, _HTTPMinorVersion }]; [request setHeaders: _headers]; [request setBody: _body]; [request setRemoteAddress: [_socket remoteAddress]]; response = [[[OFHTTPServerResponse alloc] initWithSocket: _socket server: _server request: request] autorelease]; [[_server delegate] server: _server didReceiveRequest: request response: response]; } @end |
︙ | ︙ |