You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
2.6 KiB

From: "Jyri J. Virkki" <jyri@virkki.com>
Date: Sun, 6 Jan 2013 02:21:09 -0800
Subject: =?UTF-8?q?Fix=20header=20parsing=20to=20compare=20HTTP=20header=20f?=
=?UTF-8?q?ield=20names=20case=0Ainsensitively.=20This=20fixes=20the=20probl?=
=?UTF-8?q?em=20where=20responses=20get=20incorrectly=0Amarked=20as=20errors?=
=?UTF-8?q?=20if=20the=20response=20header=20field=20name=20case=20doesn't=20?=
=?UTF-8?q?happen=0Ato=20match=20to=20what=20is=20in=20the=20code.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Also compare connection and transfer-encoding tokens case insensitively.
(Reference: RFC 2616: header field names are not case sensitive.)
Co-authored-by: Stefan Bühler <stbuehler@web.de>
---
src/client.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/client.c b/src/client.c
index f8875e4..dd48265 100644
--- a/src/client.c
+++ b/src/client.c
@@ -379,26 +379,24 @@ static uint8_t client_parse(Client *client, int size) {
str = &client->buffer[client->parser_offset];
//printf("checking header: '%s'\n", str);
- if (strncmp(str, "Content-Length: ", sizeof("Content-Length: ")-1) == 0) {
+ if (strncasecmp(str, "Content-Length: ", sizeof("Content-Length: ")-1) == 0) {
/* content length header */
client->content_length = str_to_uint64(str + sizeof("Content-Length: ") - 1);
- } else if (strncmp(str, "Connection: ", sizeof("Connection: ")-1) == 0) {
+ } else if (strncasecmp(str, "Connection: ", sizeof("Connection: ")-1) == 0) {
/* connection header */
str += sizeof("Connection: ") - 1;
- if (strncmp(str, "close", sizeof("close")-1) == 0)
+ if (strncasecmp(str, "close", sizeof("close")-1) == 0)
client->keepalive = 0;
- else if (strncmp(str, "Keep-Alive", sizeof("Keep-Alive")-1) == 0)
- client->keepalive = client->worker->config->keep_alive;
- else if (strncmp(str, "keep-alive", sizeof("keep-alive")-1) == 0)
+ else if (strncasecmp(str, "keep-alive", sizeof("keep-alive")-1) == 0)
client->keepalive = client->worker->config->keep_alive;
else
return 0;
- } else if (strncmp(str, "Transfer-Encoding: ", sizeof("Transfer-Encoding: ")-1) == 0) {
+ } else if (strncasecmp(str, "Transfer-Encoding: ", sizeof("Transfer-Encoding: ")-1) == 0) {
/* transfer encoding header */
str += sizeof("Transfer-Encoding: ") - 1;
- if (strncmp(str, "chunked", sizeof("chunked")-1) == 0)
+ if (strncasecmp(str, "chunked", sizeof("chunked")-1) == 0)
client->chunked = 1;
else
return 0;