Overview
Comment: | ofhttp: Print the HTTP status code on error
Without this, there would be no indication of the error when using -q. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9c506fc99595900af3c122d0627ff9f5 |
User & Date: | js on 2020-03-22 15:51:59 |
Other Links: | manifest | tags |
Context
2020-03-22
| ||
16:15 | ofhttp: Allow all request methods check-in: a013a9d577 user: js tags: trunk | |
15:51 | ofhttp: Print the HTTP status code on error check-in: 9c506fc995 user: js tags: trunk | |
2020-03-21
| ||
12:09 | .travis.yml: Update webhook URL check-in: 305688321e user: js tags: trunk | |
Changes
Modified src/OFHTTPResponse.h from [f70ef56750] to [453ae309af].
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 | * @brief Returns the reply as a string, trying to detect the encoding and * falling back to the specified encoding if not detectable. * * @return The reply as a string */ - (OFString *)stringWithEncoding: (of_string_encoding_t)encoding; @end OF_ASSUME_NONNULL_END | > > > > > > > > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | * @brief Returns the reply as a string, trying to detect the encoding and * falling back to the specified encoding if not detectable. * * @return The reply as a string */ - (OFString *)stringWithEncoding: (of_string_encoding_t)encoding; @end #ifdef __cplusplus extern "C" { #endif extern OFString *_Nonnull of_http_status_code_to_string(short code); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFHTTPResponse.m from [2d50b8bc91] to [651e588aea].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #import "OFData.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" static of_string_encoding_t encodingForContentType(OFString *contentType) { const char *UTF8String = contentType.UTF8String; size_t last, length = contentType.UTF8StringLength; enum { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #import "OFData.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" OFString * of_http_status_code_to_string(short code) { switch (code) { case 100: return @"Continue"; case 101: return @"Switching Protocols"; case 200: return @"OK"; case 201: return @"Created"; case 202: return @"Accepted"; case 203: return @"Non-Authoritative Information"; case 204: return @"No Content"; case 205: return @"Reset Content"; case 206: return @"Partial Content"; case 300: return @"Multiple Choices"; case 301: return @"Moved Permanently"; case 302: return @"Found"; case 303: return @"See Other"; case 304: return @"Not Modified"; case 305: return @"Use Proxy"; case 307: return @"Temporary Redirect"; case 400: return @"Bad Request"; case 401: return @"Unauthorized"; case 402: return @"Payment Required"; case 403: return @"Forbidden"; case 404: return @"Not Found"; case 405: return @"Method Not Allowed"; case 406: return @"Not Acceptable"; case 407: return @"Proxy Authentication Required"; case 408: return @"Request Timeout"; case 409: return @"Conflict"; case 410: return @"Gone"; case 411: return @"Length Required"; case 412: return @"Precondition Failed"; case 413: return @"Request Entity Too Large"; case 414: return @"Request-URI Too Long"; case 415: return @"Unsupported Media Type"; case 416: return @"Requested Range Not Satisfiable"; case 417: return @"Expectation Failed"; case 500: return @"Internal Server Error"; case 501: return @"Not Implemented"; case 502: return @"Bad Gateway"; case 503: return @"Service Unavailable"; case 504: return @"Gateway Timeout"; case 505: return @"HTTP Version Not Supported"; default: return @"(unknown)"; } } static of_string_encoding_t encodingForContentType(OFString *contentType) { const char *UTF8String = contentType.UTF8String; size_t last, length = contentType.UTF8StringLength; enum { |
︙ | ︙ |
Modified src/OFHTTPServer.m from [e03c4b06ca] to [69c85c4501].
︙ | ︙ | |||
109 110 111 112 113 114 115 | #ifdef OF_HAVE_THREADS @interface OFHTTPServerThread: OFThread - (void)stop; @end #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | #ifdef OF_HAVE_THREADS @interface OFHTTPServerThread: OFThread - (void)stop; @end #endif static OF_INLINE OFString * normalizedKey(OFString *key) { char *cString = of_strdup(key.UTF8String); unsigned char *tmp = (unsigned char *)cString; bool firstLetter = true; |
︙ | ︙ | |||
261 262 263 264 265 266 267 | - (void)of_sendHeaders { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; | | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | - (void)of_sendHeaders { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [_socket writeFormat: @"HTTP/%@ %d %@\r\n", self.protocolVersionString, _statusCode, of_http_status_code_to_string(_statusCode)]; headers = [[_headers mutableCopy] autorelease]; if ([headers objectForKey: @"Date"] == nil) { OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; |
︙ | ︙ | |||
580 581 582 583 584 585 586 | } - (bool)sendErrorAndClose: (short)statusCode { OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; | | | > | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | } - (bool)sendErrorAndClose: (short)statusCode { OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; [_socket writeFormat: @"HTTP/1.1 %d %@\r\n" @"Date: %@\r\n" @"Server: %@\r\n" @"\r\n", statusCode, of_http_status_code_to_string(statusCode), date, _server.name]; return false; } - (void)createResponse { |
︙ | ︙ |
Modified utils/ofhttp/OFHTTP.m from [fb786804a8] to [39d0dcb133].
︙ | ︙ | |||
678 679 680 681 682 683 684 685 | @"%[prog]: Failed to download <%[url]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @"error", error, @"exception", e)]; } else if ([e isKindOfClass: [OFHTTPRequestFailedException class]]) { [of_stderr writeLine: OF_LOCALIZED(@"download_failed", | > > > | > | > | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | @"%[prog]: Failed to download <%[url]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @"error", error, @"exception", e)]; } else if ([e isKindOfClass: [OFHTTPRequestFailedException class]]) { short statusCode = [[e response] statusCode]; OFString *codeString = [OFString stringWithFormat: @"%d %@", statusCode, of_http_status_code_to_string(statusCode)]; [of_stderr writeLine: OF_LOCALIZED(@"download_failed", @"%[prog]: Failed to download <%[url]>!\n" @" HTTP status code: %[code]", @"prog", [OFApplication programName], @"url", request.URL.string, @"code", codeString)]; } else @throw e; _errorCode = 1; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } |
︙ | ︙ | |||
709 710 711 712 713 714 715 | if (!_quiet) [of_stdout writeString: @"\n Error!\n"]; URL = [_URLs objectAtIndex: _URLIndex - 1]; [of_stderr writeLine: OF_LOCALIZED( @"download_failed_exception", | | > | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | if (!_quiet) [of_stdout writeString: @"\n Error!\n"]; URL = [_URLs objectAtIndex: _URLIndex - 1]; [of_stderr writeLine: OF_LOCALIZED( @"download_failed_exception", @"%[prog]: Failed to download <%[url]>!\n" @" %[exception]", @"prog", [OFApplication programName], @"url", URL, @"exception", exception)]; _errorCode = 1; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; |
︙ | ︙ |
Modified utils/ofhttp/lang/de.json from [9e4f95f1d1] to [ed88980c09].
︙ | ︙ | |||
59 60 61 62 63 64 65 | "download_failed_read_or_write_failed_any": "Lesen oder Schreiben", "download_failed_read_or_write_failed_read": "Lesen", "download_failed_read_or_write_failed_write": "Schreiben", "download_failed_read_or_write_failed": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " %[error]: %[exception]" ], | > | > > | > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | "download_failed_read_or_write_failed_any": "Lesen oder Schreiben", "download_failed_read_or_write_failed_read": "Lesen", "download_failed_read_or_write_failed_write": "Schreiben", "download_failed_read_or_write_failed": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " %[error]: %[exception]" ], "download_failed": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " HTTP Status-Code: %[code]" ], "download_failed_exception": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " %[exception]" ], "download_done": "Fertig!", "invalid_url": "%[prog]: Ungültige URL: <%[url]>!", "invalid_scheme": "%[prog]: Ungültiges Schema: <%[url]>!", "type_unknown": "unbekannt", "size_gib": "%[num] GiB", "size_mib": "%[num] MiB", |
︙ | ︙ |