Differences From Artifact [28acc739df]:
- File
src/OFHTTPServer.m
— part of check-in
[6e42ee482f]
at
2020-10-10 10:58:30
on branch trunk
— Make HTTP status code consistently a short
It used to be a short in some places and an int in other places. (user: js, size: 21688) [annotate] [blame] [check-ins using]
To Artifact [59a786282c]:
- File src/OFHTTPServer.m — part of check-in [4bbac7ab17] at 2020-11-01 11:35:03 on branch trunk — OFString: Add -[substring{From,To}Index:] (user: js, size: 21410) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
372 373 374 375 376 377 378 | return [self sendErrorAndClose: 400]; } pos = [line rangeOfString: @" "].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | return [self sendErrorAndClose: 400]; } pos = [line rangeOfString: @" "].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; method = [line substringToIndex: pos]; @try { _method = of_http_request_method_from_string(method); } @catch (OFInvalidArgumentException *e) { return [self sendErrorAndClose: 405]; } @try { |
︙ | ︙ | |||
448 449 450 451 452 453 454 | return false; } pos = [line rangeOfString: @":"].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; | | | < | < < < | | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | return false; } pos = [line rangeOfString: @":"].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; key = [line substringToIndex: pos]; value = [line substringFromIndex: pos + 1]; key = normalizedKey(key.stringByDeletingTrailingWhitespaces); value = value.stringByDeletingLeadingWhitespaces; old = [_headers objectForKey: key]; if (old != nil) value = [old stringByAppendingFormat: @",%@", value]; [_headers setObject: value forKey: key]; if ([key isEqual: @"Host"]) { pos = [value rangeOfString: @":" options: OF_STRING_SEARCH_BACKWARDS].location; if (pos != OF_NOT_FOUND) { [_host release]; _host = [[value substringToIndex: pos] retain]; @try { unsigned long long portTmp = [value substringFromIndex: pos + 1] .unsignedLongLongValue; if (portTmp < 1 || portTmp > UINT16_MAX) return [self sendErrorAndClose: 400]; _port = (uint16_t)portTmp; } @catch (OFInvalidFormatException *e) { |
︙ | ︙ | |||
544 545 546 547 548 549 550 | URL.host = _host; if (_port != 80) URL.port = [OFNumber numberWithUnsignedShort: _port]; if ((pos = [_path rangeOfString: @"?"].location) != OF_NOT_FOUND) { OFString *path, *query; | | | < | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | URL.host = _host; if (_port != 80) URL.port = [OFNumber numberWithUnsignedShort: _port]; if ((pos = [_path rangeOfString: @"?"].location) != OF_NOT_FOUND) { OFString *path, *query; path = [_path substringToIndex: pos]; query = [_path substringFromIndex: pos + 1]; URL.URLEncodedPath = path; URL.URLEncodedQuery = query; } else URL.URLEncodedPath = _path; [URL makeImmutable]; |
︙ | ︙ | |||
694 695 696 697 698 699 700 | if (_toRead == 0) _toRead = -2; return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; | | | | | < | < | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | if (_toRead == 0) _toRead = -2; return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; size_t pos; unsigned long long toRead; @try { line = [_socket tryReadLine]; } @catch (OFInvalidEncodingException *e) { @throw [OFInvalidFormatException exception]; } if (line == nil) return 0; pos = [line rangeOfString: @";"].location; if (pos != OF_NOT_FOUND) line = [line substringToIndex: pos]; if (line.length < 1) { /* * We have read the empty string because the socket is * at end of stream. */ if (_socket.atEndOfStream && pos == OF_NOT_FOUND) @throw [OFTruncatedDataException exception]; else @throw [OFInvalidFormatException exception]; } toRead = [line unsignedLongLongValueWithBase: 16]; if (toRead > LLONG_MAX) |
︙ | ︙ |