summaryrefslogtreecommitdiff
path: root/src/client/HTTP.cpp
diff options
context:
space:
mode:
authorSimon 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)
commit261c654ca0978cdc39c9670050c307fe0065fac1 (patch)
tree76fedadae55f201d76a74741acdfc74cd5576909 /src/client/HTTP.cpp
parent92dd8ac8043a654821e2d48fab3f4e764cddb1f7 (diff)
downloadpowder-261c654ca0978cdc39c9670050c307fe0065fac1.zip
powder-261c654ca0978cdc39c9670050c307fe0065fac1.tar.gz
HTTP/1.1: Allow multiple whitespace characters in header fields
Diffstat (limited to 'src/client/HTTP.cpp')
-rw-r--r--src/client/HTTP.cpp30
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;
}
}