Commit d16dbc19 authored by Serge A. Zaitsev's avatar Serge A. Zaitsev Committed by Cesanta Bot

mongoose: fix http pipeline

mongoose: fix formatting

mongoose: fix formatting

mongoose: remove debugging messages

PUBLISHED_FROM=1194e018001cc5f2b598096593d7aac4ec8dc04d
parent 127f27e3
......@@ -6159,6 +6159,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
}
#endif /* MG_ENABLE_HTTP_STREAMING_MULTIPART */
again:
req_len = mg_parse_http(io->buf, io->len, hm, is_req);
if (req_len > 0 &&
......@@ -6252,7 +6253,10 @@ void mg_http_handler(struct mg_connection *nc, int ev,
/* Whole HTTP message is fully buffered, call event handler */
mg_http_call_endpoint_handler(nc, trigger_ev, hm);
mbuf_remove(io, hm->message.len);
pd->rcvd = 0;
pd->rcvd -= hm->message.len;
if (io->len > 0) {
goto again;
}
}
}
}
......
......@@ -787,6 +787,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
}
#endif /* MG_ENABLE_HTTP_STREAMING_MULTIPART */
again:
req_len = mg_parse_http(io->buf, io->len, hm, is_req);
if (req_len > 0 &&
......@@ -880,7 +881,10 @@ void mg_http_handler(struct mg_connection *nc, int ev,
/* Whole HTTP message is fully buffered, call event handler */
mg_http_call_endpoint_handler(nc, trigger_ev, hm);
mbuf_remove(io, hm->message.len);
pd->rcvd = 0;
pd->rcvd -= hm->message.len;
if (io->len > 0) {
goto again;
}
}
}
}
......
......@@ -2057,20 +2057,19 @@ static void http_pipeline_handler(struct mg_connection *c, int ev,
int *status = (int *) c->mgr->user_data;
if (ev == MG_EV_HTTP_REQUEST) {
/* Server request handler */
mg_send_response_line(c, 200, "Content-Type: text/plain\r\n");
mg_send_response_line(c, 200,
"Content-Type: text/plain\r\nContent-Length: 5\r\n");
mg_printf(c, "Hello");
c->flags |= MG_F_SEND_AND_CLOSE;
*status = *status + 1;
} else if (ev == MG_EV_HTTP_REPLY) {
/* Client reply handler */
*status = *status + 10;
c->flags |= MG_F_CLOSE_IMMEDIATELY;
}
}
static const char *test_http_pipeline(void) {
struct mg_mgr mgr;
struct mg_connection *lc, *nc1, *nc2;
struct mg_connection *lc, *nc1;
const char *local_addr = "127.0.0.1:7777";
int status = 0;
......@@ -2079,10 +2078,7 @@ static const char *test_http_pipeline(void) {
mg_set_protocol_http_websocket(lc);
ASSERT(nc1 = mg_connect(&mgr, local_addr, http_pipeline_handler));
mg_set_protocol_http_websocket(nc1);
mg_printf(nc1, "GET / HTTP/1.1\r\n\r\n");
ASSERT(nc2 = mg_connect(&mgr, local_addr, http_pipeline_handler));
mg_set_protocol_http_websocket(nc2);
mg_printf(nc2, "GET / HTTP/1.1\r\n\r\n");
mg_printf(nc1, "GET / HTTP/1.1\r\n\r\nGET / HTTP/1.1\r\n\r\n");
poll_until(&mgr, 1, c_int_eq, &status, (void *) 22);
ASSERT_EQ(status, 22);
mg_mgr_free(&mgr);
......
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