diff --git a/darkhttpd.c b/darkhttpd.c index 05a0daa..c6a1a02 100644 --- a/darkhttpd.c +++ b/darkhttpd.c @@ -1600,7 +1600,7 @@ static void redirect(struct connection *conn, const char *format, ...) { /* Parses a single HTTP request field. Returns string from end of [field] to * first \r, \n or end of request string. Returns NULL if [field] can't be - * matched. + * matched. Case insensitive. * * You need to remember to deallocate the result. * example: parse_field(conn, "Referer: "); @@ -1610,7 +1610,7 @@ static char *parse_field(const struct connection *conn, const char *field) { char *pos; /* find start */ - pos = strstr(conn->request, field); + pos = strcasestr(conn->request, field); if (pos == NULL) return NULL; assert(pos >= conn->request); diff --git a/devel/test.py b/devel/test.py index 8b35873..7835c0c 100755 --- a/devel/test.py +++ b/devel/test.py @@ -385,6 +385,11 @@ class TestFileGet(TestHelper): status, hdrs, body = parse(resp) self.assertContains(status, "416 Requested Range Not Satisfiable") + def test_lowercase_header(self): + resp = self.get(self.url, req_hdrs = {"range": "bytes=20-10"}) + status, hdrs, body = parse(resp) + self.assertContains(status, "416 Requested Range Not Satisfiable") + class TestKeepAlive(TestFileGet): """ Run all of TestFileGet but with a single long-lived connection.