mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-04 21:58:22 +00:00
Fix mg_http_parse_headers
PUBLISHED_FROM=7e88f60283d499732e8df663814067849d9567bb
This commit is contained in:
1 parent
7414a4fb06
commit
0ec1a141f1
1 file changed
+13
-2
+13
-2
@@ -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,
|
static const char *mg_http_parse_headers(const char *s, const char *end,
|
||||||
int len, struct http_message *req) {
|
int len, struct http_message *req) {
|
||||||
int i;
|
int i = 0;
|
||||||
for (i = 0; i < (int) ARRAY_SIZE(req->header_names) - 1; i++) {
|
while (i < (int) ARRAY_SIZE(req->header_names) - 1) {
|
||||||
struct mg_str *k = &req->header_names[i], *v = &req->header_values[i];
|
struct mg_str *k = &req->header_names[i], *v = &req->header_values[i];
|
||||||
|
|
||||||
s = mg_skip(s, end, ": ", k);
|
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 */
|
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) {
|
if (k->len == 0 || v->len == 0) {
|
||||||
k->p = v->p = NULL;
|
k->p = v->p = NULL;
|
||||||
k->len = v->len = 0;
|
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->body.len = (size_t) to64(v->p);
|
||||||
req->message.len = len + req->body.len;
|
req->message.len = len + req->body.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
Reference in new issue
Block a user