mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-31 13:00:49 +00:00
Avoid computing offset twice
This commit is contained in:
1 parent
b938728c2a
commit
9123330f72
3 files changed
+12
-2
No files matched your search
+2
-1
@@ -4785,8 +4785,9 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
// contain a Content-length header (unless the body length is 0, in
|
||||
// which case it can be omitted). Other requests can also contain a
|
||||
// body, but their content has no defined semantics (RFC 7231)
|
||||
// It is a non-chunked request, so the offset (ofs) is updated after
|
||||
// exiting this branch.
|
||||
if (hm.body.len != 0) 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.
|
||||
|
||||
+2
-1
@@ -1183,8 +1183,9 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
// contain a Content-length header (unless the body length is 0, in
|
||||
// which case it can be omitted). Other requests can also contain a
|
||||
// body, but their content has no defined semantics (RFC 7231)
|
||||
// It is a non-chunked request, so the offset (ofs) is updated after
|
||||
// exiting this branch.
|
||||
if (hm.body.len != 0) 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.
|
||||
|
||||
@@ -1758,6 +1758,14 @@ static void test_http_pipeline(void) {
|
||||
for (i = 0; i < 20; i++) mg_mgr_poll(&mgr, 1);
|
||||
ASSERT(ok == 1);
|
||||
ASSERT(ok2 == 1);
|
||||
// A bodyless POST must not consume the following pipelined request
|
||||
ok = ok2 = 0;
|
||||
c = mg_http_connect(&mgr, url, f6, (void *) &ok2);
|
||||
mg_printf(c, "POST /x HTTP/1.1\r\nHost: h\r\n\r\n"
|
||||
"GET /next HTTP/1.1\r\nHost: h\r\n\r\n");
|
||||
for (i = 0; i < 20; i++) mg_mgr_poll(&mgr, 1);
|
||||
ASSERT(ok == 2);
|
||||
ASSERT(ok2 == 2);
|
||||
// MG_INFO(("-----> [%d] [%d]", ok, ok2));
|
||||
mg_mgr_free(&mgr);
|
||||
ASSERT(mgr.conns == NULL);
|
||||
|
||||
Reference in new issue
Block a user