Commit 0ec1a141 authored by Alexander Alashkin's avatar Alexander Alashkin Committed by Cesanta Bot

Fix mg_http_parse_headers

PUBLISHED_FROM=7e88f60283d499732e8df663814067849d9567bb
parent 7414a4fb
......@@ -4045,8 +4045,8 @@ static int mg_http_get_request_len(const char *s, int buf_len) {
static const char *mg_http_parse_headers(const char *s, const char *end,
int len, struct http_message *req) {
int i;
for (i = 0; i < (int) ARRAY_SIZE(req->header_names) - 1; i++) {
int i = 0;
while (i < (int) ARRAY_SIZE(req->header_names) - 1) {
struct mg_str *k = &req->header_names[i], *v = &req->header_values[i];
s = mg_skip(s, end, ": ", k);
......@@ -4056,6 +4056,15 @@ static const char *mg_http_parse_headers(const char *s, const char *end,
v->len--; /* Trim trailing spaces in header value */
}
/*
* If header value is empty - skip it and go to next (if any).
* NOTE: Do not add it to headers_values because such addition changes API
* behaviour
*/
if (k->len != 0 && v->len == 0) {
continue;
}
if (k->len == 0 || v->len == 0) {
k->p = v->p = NULL;
k->len = v->len = 0;
......@@ -4066,6 +4075,8 @@ static const char *mg_http_parse_headers(const char *s, const char *end,
req->body.len = (size_t) to64(v->p);
req->message.len = len + req->body.len;
}
i++;
}
return s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment