src: use memchr() in h_general header value

make-http-max-header-size-gyp-configurable
Fedor Indutny 10 years ago
parent c6097e1d76
commit 0097de5895

@ -1516,16 +1516,29 @@ size_t http_parser_execute (http_parser *parser,
switch (h_state) { switch (h_state) {
case h_general: case h_general:
for (; p != data + len; p++) { {
ch = *p; const char* p_cr;
if (ch == CR || ch == LF) { const char* p_lf;
--p; size_t limit = data + len - p;
break;
} limit = MIN(limit, HTTP_MAX_HEADER_SIZE);
p_cr = memchr(p, CR, limit);
p_lf = memchr(p, LF, limit);
if (p_cr != NULL) {
if (p_lf != NULL && p_cr >= p_lf)
p = p_lf;
else
p = p_cr;
} else if (p_lf != NULL) {
p = p_lf;
} else {
p = data + len;
} }
if (p == data + len) --p;
--p;
break; break;
}
case h_connection: case h_connection:
case h_transfer_encoding: case h_transfer_encoding:

Loading…
Cancel
Save