mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 06:51:04 +08:00
Merge pull request #2813 from cesanta/foureleven
fix 411 not draining header data
This commit is contained in:
commit
5ad2b0531a
@ -3258,6 +3258,7 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
// contain a Content-length header. Other requests can also contain a
|
||||
// body, but their content has no defined semantics (RFC 7231)
|
||||
require_content_len = true;
|
||||
ofs += (size_t) n; // this request has been processed
|
||||
} else if (is_response) {
|
||||
// HTTP spec 7.2 Entity body: All other responses must include a body
|
||||
// or Content-Length header field defined with a value of 0.
|
||||
|
@ -1042,6 +1042,7 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
// contain a Content-length header. Other requests can also contain a
|
||||
// body, but their content has no defined semantics (RFC 7231)
|
||||
require_content_len = true;
|
||||
ofs += (size_t) n; // this request has been processed
|
||||
} else if (is_response) {
|
||||
// HTTP spec 7.2 Entity body: All other responses must include a body
|
||||
// or Content-Length header field defined with a value of 0.
|
||||
|
@ -865,7 +865,8 @@ static void fprcb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
struct fpr_data *fd = (struct fpr_data *) c->fn_data;
|
||||
if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
if (atoi(hm->uri.buf) == 200) {
|
||||
int code = atoi(hm->uri.buf);
|
||||
if (code == 200) {
|
||||
snprintf(fd->buf + fd->len, FETCH_BUF_SIZE - (unsigned int) fd->len, "%.*s", (int) hm->message.len,
|
||||
hm->message.buf);
|
||||
fd->len += (int) hm->message.len;
|
||||
@ -874,6 +875,9 @@ static void fprcb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
fd->closed = 1;
|
||||
c->is_closing = 1;
|
||||
}
|
||||
} else { // allow testing for other codes and catching wrong responses
|
||||
MG_INFO(("reqs: %d, code: %d", fd->reqs, code));
|
||||
fd->reqs += code;
|
||||
}
|
||||
(void) c;
|
||||
} else if (ev == MG_EV_CLOSE) {
|
||||
@ -1434,6 +1438,8 @@ static void test_http_no_content_length(void) {
|
||||
ASSERT(fetch(&mgr, buf, url, "HTTP/1.1 304\r\n\r\n") != 411);
|
||||
ASSERT(fetch(&mgr, buf, url, "HTTP/1.1 305\r\n\r\n") == 411);
|
||||
ASSERT(fetch(&mgr, buf, url, post_req) != 411);
|
||||
// Check it is processed only once (see #2811)
|
||||
ASSERT(fpr(&mgr, buf, url, "POST / HTTP/1.1\r\n\r\n") == 411);
|
||||
mg_mgr_free(&mgr);
|
||||
ASSERT(mgr.conns == NULL);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user