Differences From Artifact [339d905a8d]:
- File
src/OFHTTPServer.m
— part of check-in
[2f4e0df8be]
at
2017-10-17 00:33:37
on branch trunk
— Do not use implicit method return types
Instead, explicitly declare them, as OF_ASSUME_NONNULL_{BEGIN,END} does
not apply to implicit return types. This means that after this commit,
all init methods have a nonnull return type, as they should have. (user: js, size: 16887) [annotate] [blame] [check-ins using]
To Artifact [a75e2ea261]:
- File src/OFHTTPServer.m — part of check-in [a06354b42a] at 2017-10-22 15:05:39 on branch trunk — Make Apple GCC with -Wshadow happy (user: js, size: 16862) [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 *)sock didAcceptSocket: (OFTCPSocket *)clientSocket context: (id)context exception: (id)exception; @end static const char * statusCodeToString(short code) |
︙ | ︙ | |||
176 177 178 179 180 181 182 | { OFTCPSocket *_socket; OFHTTPServer *_server; OFHTTPRequest *_request; bool _chunked, _headersSent; } | | | | | 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 | { OFTCPSocket *_socket; OFHTTPServer *_server; OFHTTPRequest *_request; bool _chunked, _headersSent; } - (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server request: (OFHTTPRequest *)request; @end @implementation OFHTTPServerResponse - (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server request: (OFHTTPRequest *)request { self = [super init]; _statusCode = 500; _socket = [sock retain]; _server = [server retain]; _request = [request retain]; return self; } - (void)dealloc |
︙ | ︙ | |||
337 338 339 340 341 342 343 | OFString *_host, *_path; uint16_t _port; OFMutableDictionary *_headers; size_t _contentLength; OFMutableData *_body; } | | | | | | | | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | OFString *_host, *_path; uint16_t _port; OFMutableDictionary *_headers; size_t _contentLength; OFMutableData *_body; } - (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server; - (bool)socket: (OFTCPSocket *)sock didReadLine: (OFString *)line context: (id)context exception: (id)exception; - (bool)parseProlog: (OFString *)line; - (bool)parseHeaders: (OFString *)line; - (bool)socket: (OFTCPSocket *)sock didReadIntoBuffer: (char *)buffer length: (size_t)length context: (id)context exception: (id)exception; - (bool)sendErrorAndClose: (short)statusCode; - (void)createResponse; @end @implementation OFHTTPServer_Connection - (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server { self = [super init]; @try { _socket = [sock retain]; _server = [server retain]; _timer = [[OFTimer scheduledTimerWithTimeInterval: 10 target: _socket selector: @selector( cancelAsyncRequests) repeats: false] retain]; _state = AWAITING_PROLOG; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
394 395 396 397 398 399 400 | [_path release]; [_headers release]; [_body release]; [super dealloc]; } | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | [_path release]; [_headers release]; [_body release]; [super dealloc]; } - (bool)socket: (OFTCPSocket *)sock didReadLine: (OFString *)line context: (id)context exception: (id)exception { if (line == nil || exception != nil) return false; |
︙ | ︙ | |||
573 574 575 576 577 578 579 | _port = 80; } } return true; } | | | | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | _port = 80; } } return true; } - (bool)socket: (OFTCPSocket *)sock didReadIntoBuffer: (char *)buffer length: (size_t)length context: (id)context exception: (id)exception { if ([sock isAtEndOfStream] || exception != nil) return false; [_body addItems: buffer count: length]; if ([_body count] >= _contentLength) { /* |
︙ | ︙ | |||
739 740 741 742 743 744 745 | - (void)stop { [_listeningSocket cancelAsyncRequests]; [_listeningSocket release]; _listeningSocket = nil; } | | | 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | - (void)stop { [_listeningSocket cancelAsyncRequests]; [_listeningSocket release]; _listeningSocket = nil; } - (bool)of_socket: (OFTCPSocket *)sock didAcceptSocket: (OFTCPSocket *)clientSocket context: (id)context exception: (id)exception { OFHTTPServer_Connection *connection; if (exception != nil) { |
︙ | ︙ |