Differences From Artifact [6f3529bdbf]:
- File
src/OFHTTPServer.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 16552) [annotate] [blame] [check-ins using]
To Artifact [4d2868ce13]:
- File
src/OFHTTPServer.m
— part of check-in
[6b77a5dd8b]
at
2017-05-21 21:28:57
on branch trunk
— Prefix private methods with of_ instead of OF_
This matches Apple's style. (user: js, size: 16552) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
43 44 45 46 47 48 49 | /* * FIXME: Key normalization replaces headers like "DNT" with "Dnt". * FIXME: Errors are not reported to the user. */ @interface OFHTTPServer () | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* * FIXME: Key normalization replaces headers like "DNT" with "Dnt". * FIXME: Errors are not reported to the user. */ @interface OFHTTPServer () - (bool)of_socket: (OFTCPSocket *)socket didAcceptSocket: (OFTCPSocket *)clientSocket exception: (OFException *)exception; @end static const char * statusCodeToString(short code) { |
︙ | ︙ | |||
206 207 208 209 210 211 212 | [_server release]; [_request release]; [super dealloc]; } | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | [_server release]; [_request release]; [super dealloc]; } - (void)of_sendHeaders { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [_socket writeFormat: @"HTTP/%@ %d %s\r\n", |
︙ | ︙ | |||
259 260 261 262 263 264 265 | { void *pool; if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (!_headersSent) | | | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | { void *pool; if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (!_headersSent) [self of_sendHeaders]; if (!_chunked) { [_socket writeBuffer: buffer length: length]; return; } |
︙ | ︙ | |||
284 285 286 287 288 289 290 | - (void)close { if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { if (!_headersSent) | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | - (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]; |
︙ | ︙ | |||
715 716 717 718 719 720 721 | _listeningSocket = [[OFTCPSocket alloc] init]; _port = [_listeningSocket bindToHost: _host port: _port]; [_listeningSocket listen]; [_listeningSocket asyncAcceptWithTarget: self | | | | 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | _listeningSocket = [[OFTCPSocket alloc] init]; _port = [_listeningSocket bindToHost: _host port: _port]; [_listeningSocket listen]; [_listeningSocket asyncAcceptWithTarget: self selector: @selector(of_socket: didAcceptSocket: exception:)]; } - (void)stop { [_listeningSocket cancelAsyncRequests]; [_listeningSocket release]; _listeningSocket = nil; } - (bool)of_socket: (OFTCPSocket *)socket didAcceptSocket: (OFTCPSocket *)clientSocket exception: (OFException *)exception { OFHTTPServer_Connection *connection; if (exception != nil) { if ([_delegate respondsToSelector: |
︙ | ︙ |