wget: strip trailing whitespace from e.g. "Content-length: 120 "
No binary (build failed)
—
(log yok)
| @@ -880,7 +880,14 @@ However, in real world it was observed that some web servers | |
| */ | |
| while ((str = gethdr(buf, sizeof(buf), sfp /*, &n*/)) != NULL) { | |
| /* gethdr converted "FOO:" string to lowercase */ | |
| - | smalluint key = index_in_strings(keywords, buf) + 1; |
| + | smalluint key; |
| + | /* strip trailing whitespace */ |
| + | char *s = strchrnul(str, '\0') - 1; |
| + | while (s >= str && (*s == ' ' || *s == '\t')) { |
| + | *s = '\0'; |
| + | s--; |
| + | } |
| + | key = index_in_strings(keywords, buf) + 1; |
| if (key == KEY_content_length) { | |
| content_len = BB_STRTOOFF(str, NULL, 10); | |
| if (errno || content_len < 0) { | |