header parsing: allow tabs are whitespace, compare case-insensitive

this is more conforming the HTTP spec
This commit is contained in:
Hiltjo Posthuma 2017-06-27 22:19:27 +02:00 committed by Laslo Hunhold
parent 2021da9bed
commit d1589c96fa

View file

@ -271,7 +271,7 @@ getrequest(int fd, struct request *r)
/* match field type */ /* match field type */
for (; *p != '\0';) { for (; *p != '\0';) {
for (i = 0; i < NUM_REQ_FIELDS; i++) { for (i = 0; i < NUM_REQ_FIELDS; i++) {
if (!strncmp(p, req_field_str[i], if (!strncasecmp(p, req_field_str[i],
strlen(req_field_str[i]))) { strlen(req_field_str[i]))) {
break; break;
} }
@ -293,7 +293,7 @@ getrequest(int fd, struct request *r)
} }
/* skip whitespace */ /* skip whitespace */
for (++p; *p == ' '; p++) for (++p; *p == ' ' || *p == '\t'; p++)
; ;
/* extract field content */ /* extract field content */