Overview
Comment: | Small improvements for OFHTTPClient & OFHTTPServer |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0a249f58cf6176dcd67b0aeb3d02d3ee |
User & Date: | js on 2015-04-26 08:54:21 |
Other Links: | manifest | tags |
Context
2015-04-26
| ||
10:40 | OFKernelEventObserver: Rename a private method check-in: bd05eb8de3 user: js tags: trunk | |
08:54 | Small improvements for OFHTTPClient & OFHTTPServer check-in: 0a249f58cf user: js tags: trunk | |
08:10 | Minor improvements, no functional change check-in: 57b6030b14 user: js tags: trunk | |
Changes
Modified src/OFDataArray.m from [9e23204c7f] to [f234733150].
︙ | ︙ | |||
237 238 239 240 241 242 243 | [self freeMemory: buffer]; } headers = [response headers]; if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil) if ([self count] != | | | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | [self freeMemory: buffer]; } headers = [response headers]; if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil) if ([self count] != [contentLength decimalValue]) @throw [OFTruncatedDataException exception]; } @catch (id e) { [self release]; @throw e; } } else |
︙ | ︙ |
Modified src/OFHTTPClient.m from [7ed76f14fb] to [acbbb93d88].
︙ | ︙ | |||
106 107 108 109 110 111 112 | isEqual: @"chunked"]; contentLength = [headers objectForKey: @"Content-Length"]; if (contentLength != nil) { _hasContentLength = true; @try { | > > > > > | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | isEqual: @"chunked"]; contentLength = [headers objectForKey: @"Content-Length"]; if (contentLength != nil) { _hasContentLength = true; @try { intmax_t toRead = [contentLength decimalValue]; if (toRead > SIZE_MAX) @throw [OFOutOfRangeException exception]; _toRead = (size_t)toRead; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exception]; } } } - (size_t)lowlevelReadIntoBuffer: (void*)buffer |
︙ | ︙ | |||
183 184 185 186 187 188 189 | range = [line rangeOfString: @";"]; if (range.location != OF_NOT_FOUND) line = [line substringWithRange: of_range(0, range.location)]; @try { | > > | > | > | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | range = [line rangeOfString: @";"]; if (range.location != OF_NOT_FOUND) line = [line substringWithRange: of_range(0, range.location)]; @try { uintmax_t toRead = [line hexadecimalValue]; if (toRead > SIZE_MAX) @throw [OFOutOfRangeException exception]; _toRead = (size_t)toRead; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exception]; } if (_toRead == 0) { _atEndOfStream = true; |
︙ | ︙ |
Modified src/OFHTTPServer.m from [5ac9f0f46d] to [d46048ca78].
︙ | ︙ | |||
310 311 312 313 314 315 316 | server: (OFHTTPServer*)server; - (bool)socket: (OFTCPSocket*)socket didReadLine: (OFString*)line exception: (OFException*)exception; - (bool)parseProlog: (OFString*)line; - (bool)parseHeaders: (OFString*)line; - (bool)socket: (OFTCPSocket*)socket | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | server: (OFHTTPServer*)server; - (bool)socket: (OFTCPSocket*)socket didReadLine: (OFString*)line exception: (OFException*)exception; - (bool)parseProlog: (OFString*)line; - (bool)parseHeaders: (OFString*)line; - (bool)socket: (OFTCPSocket*)socket didReadIntoBuffer: (char*)buffer length: (size_t)length exception: (OFException*)exception; - (bool)sendErrorAndClose: (short)statusCode; - (void)createResponse; @end @implementation OFHTTPServer_Connection |
︙ | ︙ | |||
453 454 455 456 457 458 459 | - (bool)parseHeaders: (OFString*)line { OFString *key, *value; size_t pos; if ([line length] == 0) { | | | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | - (bool)parseHeaders: (OFString*)line { OFString *key, *value; size_t pos; if ([line length] == 0) { intmax_t contentLength; @try { contentLength = [[_headers objectForKey: @"Content-Length"] decimalValue]; } @catch (OFInvalidFormatException *e) { return [self sendErrorAndClose: 400]; } if (contentLength > 0) { char *buffer; |
︙ | ︙ | |||
532 533 534 535 536 537 538 | } } return true; } - (bool)socket: (OFTCPSocket*)socket | | > > > > > > > > | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | } } return true; } - (bool)socket: (OFTCPSocket*)socket didReadIntoBuffer: (char*)buffer length: (size_t)length exception: (OFException*)exception { if ([socket isAtEndOfStream] || exception != nil) return false; [_entity addItems: buffer count: length]; if ([_entity count] >= _contentLength) { /* * Manually free the buffer here. While this is not required * now as the async read is the only thing referencing self and * the buffer is allocated on self, it is required once * Connection: keep-alive is implemented. */ [self freeMemory: buffer]; @try { [self createResponse]; } @catch (OFWriteFailedException *e) { return false; } return false; |
︙ | ︙ |