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) {
case h_general:
for (; p != data + len; p++) {
ch = *p;
if (ch == CR || ch == LF) {
--p;
break;
}
{
const char* p_cr;
const char* p_lf;
size_t limit = data + len - p;
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;
}
case h_connection:
case h_transfer_encoding:

Loading…
Cancel
Save