mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-06 11:22:26 +08:00
Eat prior POST data in close_local_endpoint()
This commit is contained in:
parent
7d699ea73c
commit
136c3e8200
13
mongoose.c
13
mongoose.c
@ -1901,6 +1901,7 @@ static void write_terminating_chunk(struct connection *conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void call_uri_handler(struct connection *conn) {
|
static void call_uri_handler(struct connection *conn) {
|
||||||
|
conn->mg_conn.content = conn->local_iobuf.buf;
|
||||||
if (conn->endpoint.uh->handler(&conn->mg_conn)) {
|
if (conn->endpoint.uh->handler(&conn->mg_conn)) {
|
||||||
if (conn->flags & CONN_HEADERS_SENT) {
|
if (conn->flags & CONN_HEADERS_SENT) {
|
||||||
write_terminating_chunk(conn);
|
write_terminating_chunk(conn);
|
||||||
@ -2186,7 +2187,6 @@ static void call_uri_handler_if_data_is_buffered(struct connection *conn) {
|
|||||||
struct iobuf *loc = &conn->local_iobuf;
|
struct iobuf *loc = &conn->local_iobuf;
|
||||||
struct mg_connection *c = &conn->mg_conn;
|
struct mg_connection *c = &conn->mg_conn;
|
||||||
|
|
||||||
c->content = loc->buf;
|
|
||||||
#ifndef NO_WEBSOCKET
|
#ifndef NO_WEBSOCKET
|
||||||
if (conn->mg_conn.is_websocket) {
|
if (conn->mg_conn.is_websocket) {
|
||||||
do { } while (deliver_websocket_frame(conn));
|
do { } while (deliver_websocket_frame(conn));
|
||||||
@ -3539,6 +3539,13 @@ static void log_access(const struct connection *conn, const char *path) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void gobble_prior_post_data(struct iobuf *io, int len) {
|
||||||
|
if (len > 0 && len <= io->len) {
|
||||||
|
memmove(io->buf, io->buf + len, io->len - len);
|
||||||
|
io->len -= len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void close_local_endpoint(struct connection *conn) {
|
static void close_local_endpoint(struct connection *conn) {
|
||||||
// Must be done before free()
|
// Must be done before free()
|
||||||
int keep_alive = should_keep_alive(&conn->mg_conn) &&
|
int keep_alive = should_keep_alive(&conn->mg_conn) &&
|
||||||
@ -3556,6 +3563,10 @@ static void close_local_endpoint(struct connection *conn) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (conn->endpoint_type == EP_USER) {
|
||||||
|
gobble_prior_post_data(&conn->local_iobuf, conn->mg_conn.content_len);
|
||||||
|
}
|
||||||
|
|
||||||
conn->endpoint_type = EP_NONE;
|
conn->endpoint_type = EP_NONE;
|
||||||
conn->flags = 0;
|
conn->flags = 0;
|
||||||
conn->cl = conn->num_bytes_sent = conn->request_len = 0;
|
conn->cl = conn->num_bytes_sent = conn->request_len = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user