Differences From Artifact [8ee3bb44d0]:
- File
src/OFHTTPClient.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: 17745) [annotate] [blame] [check-ins using]
To Artifact [530dbe6279]:
- File
src/OFHTTPClient.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: 17739) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
66 67 68 69 70 71 72 73 | @interface OFHTTPClientResponse: OFHTTPResponse { OFTCPSocket *_socket; bool _hasContentLength, _chunked, _keepAlive, _atEndOfStream; size_t _toRead; } - initWithSocket: (OFTCPSocket *)socket; | > > < > > < < < < < | 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 | @interface OFHTTPClientResponse: OFHTTPResponse { OFTCPSocket *_socket; bool _hasContentLength, _chunked, _keepAlive, _atEndOfStream; size_t _toRead; } @property (nonatomic, setter=of_setKeepAlive:) bool of_keepAlive; - initWithSocket: (OFTCPSocket *)socket; @end @implementation OFHTTPClientResponse @synthesize of_keepAlive = _keepAlive; - initWithSocket: (OFTCPSocket *)socket { self = [super init]; _socket = [socket retain]; return self; } - (void)dealloc { [_socket release]; [super dealloc]; } |
︙ | ︙ | |||
279 280 281 282 283 284 285 | - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request { return [self performRequest: request redirects: 10]; } | | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request { return [self performRequest: request redirects: 10]; } - (OFTCPSocket *)of_closeAndCreateSocketForRequest: (OFHTTPRequest *)request { OFURL *URL = [request URL]; OFTCPSocket *socket; [self close]; if ([[URL scheme] isEqual: @"https"]) { |
︙ | ︙ | |||
365 366 367 368 369 370 371 | } } } @finally { [_lastResponse release]; _lastResponse = nil; } } else | | | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | } } } @finally { [_lastResponse release]; _lastResponse = nil; } } else socket = [self of_closeAndCreateSocketForRequest: request]; /* * As a work around for a bug with split packets in lighttpd when using * HTTPS, we construct the complete request in a buffer string and then * send it all at once. * * We do not use the socket's write buffer in case we need to resend |
︙ | ︙ | |||
472 473 474 475 476 477 478 | @try { [socket writeString: requestString]; } @catch (OFWriteFailedException *e) { if ([e errNo] != ECONNRESET && [e errNo] != EPIPE) @throw e; /* Reconnect in case a keep-alive connection timed out */ | | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | @try { [socket writeString: requestString]; } @catch (OFWriteFailedException *e) { if ([e errNo] != ECONNRESET && [e errNo] != EPIPE) @throw e; /* Reconnect in case a keep-alive connection timed out */ socket = [self of_closeAndCreateSocketForRequest: request]; [socket writeString: requestString]; } if (body != nil) [socket writeBuffer: [body items] length: [body count] * [body itemSize]]; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { @throw [OFInvalidServerReplyException exception]; } /* * It's possible that the write succeeds on a connection that is * keep-alive, but the connection has already been closed by the remote * end due to a timeout. In this case, we need to reconnect. */ if (line == nil) { socket = [self of_closeAndCreateSocketForRequest: request]; [socket writeString: requestString]; if (body != nil) [socket writeBuffer: [body items] length: [body count] * [body itemSize]]; |
︙ | ︙ | |||
603 604 605 606 607 608 609 | keepAlive = ([connectionHeader caseInsensitiveCompare: @"keep-alive"] == OF_ORDERED_SAME); else keepAlive = false; } if (keepAlive) { | | | 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | keepAlive = ([connectionHeader caseInsensitiveCompare: @"keep-alive"] == OF_ORDERED_SAME); else keepAlive = false; } if (keepAlive) { [response of_setKeepAlive: true]; _socket = [socket retain]; _lastURL = [URL copy]; _lastWasHEAD = (method == OF_HTTP_REQUEST_METHOD_HEAD); _lastResponse = [response retain]; } |
︙ | ︙ |