mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Make header parsing case insensitive.
This makes darkhttpd more useful behind an HTTP2 reverse proxy, because the HTTP2 headers are all lowercase. Suggested by: @Hill-98 Fixes #15
This commit is contained in:
parent
1759a7a7d9
commit
f0ca481fd1
@ -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
|
/* 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
|
* 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.
|
* You need to remember to deallocate the result.
|
||||||
* example: parse_field(conn, "Referer: ");
|
* example: parse_field(conn, "Referer: ");
|
||||||
@ -1610,7 +1610,7 @@ static char *parse_field(const struct connection *conn, const char *field) {
|
|||||||
char *pos;
|
char *pos;
|
||||||
|
|
||||||
/* find start */
|
/* find start */
|
||||||
pos = strstr(conn->request, field);
|
pos = strcasestr(conn->request, field);
|
||||||
if (pos == NULL)
|
if (pos == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
assert(pos >= conn->request);
|
assert(pos >= conn->request);
|
||||||
|
@ -385,6 +385,11 @@ class TestFileGet(TestHelper):
|
|||||||
status, hdrs, body = parse(resp)
|
status, hdrs, body = parse(resp)
|
||||||
self.assertContains(status, "416 Requested Range Not Satisfiable")
|
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):
|
class TestKeepAlive(TestFileGet):
|
||||||
"""
|
"""
|
||||||
Run all of TestFileGet but with a single long-lived connection.
|
Run all of TestFileGet but with a single long-lived connection.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user