diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-28 16:19:00 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-28 16:19:00 (GMT) |
| commit | 261c654ca0978cdc39c9670050c307fe0065fac1 (patch) | |
| tree | 76fedadae55f201d76a74741acdfc74cd5576909 /src/client | |
| parent | 92dd8ac8043a654821e2d48fab3f4e764cddb1f7 (diff) | |
| download | powder-261c654ca0978cdc39c9670050c307fe0065fac1.zip powder-261c654ca0978cdc39c9670050c307fe0065fac1.tar.gz | |
HTTP/1.1: Allow multiple whitespace characters in header fields
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/HTTP.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/client/HTTP.cpp b/src/client/HTTP.cpp index 71adc02..5fc4d08 100644 --- a/src/client/HTTP.cpp +++ b/src/client/HTTP.cpp @@ -76,6 +76,17 @@ static long http_timeout = 15; static int http_use_proxy = 0; static struct sockaddr_in http_proxy; +static char * eatwhitespace(char * s) +{ + while(*s) + { + if(!(*s == ' ' || *s == '\t')) + break; + s++; + } + return s; +} + static char *mystrdup(char *s) { char *x; @@ -351,17 +362,26 @@ static void process_header(struct http_ctx *cx, char *str) } if (!strncmp(str, "Content-Length: ", 16)) { - cx->contlen = atoi(str+16); + str = eatwhitespace(str+16); + cx->contlen = atoi(str); return; } - if (!strcmp(str, "Transfer-Encoding: chunked")) + if (!strncmp(str, "Transfer-Encoding: ", 19)) { - cx->chunked = 1; + str = eatwhitespace(str+19); + if(!strncmp(str, "chunked", 8)) + { + cx->chunked = 1; + } return; } - if (!strcmp(str, "Connection: close")) + if (!strncmp(str, "Connection: ", 12)) { - cx->cclose = 1; + str = eatwhitespace(str+12); + if(!strncmp(str, "close", 6)) + { + cx->cclose = 1; + } return; } } |
