From ce53e9dd2b6a0b2b498b7157a14dced5420188cf Mon Sep 17 00:00:00 2001 From: Alexander Alashkin <alexander.alashkin@cesanta.com> Date: Fri, 1 Apr 2016 17:18:54 +0100 Subject: [PATCH] Fix multipart handling for small files PUBLISHED_FROM=b43cb8ca061d50ea8c0b6b20287b9382a4a6be22 --- mongoose.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 81c6ee184..ca12c67e7 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5177,6 +5177,15 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) { mg_handle_chunked(nc, hm, io->buf + req_len, io->len - req_len); } +#ifdef MG_ENABLE_HTTP_STREAMING_MULTIPART + if (req_len > 0 && (s = mg_get_http_header(hm, "Content-Type")) != NULL && + s->len >= 9 && strncmp(s->p, "multipart", 9) == 0) { + mg_http_multipart_begin(nc, hm, req_len); + mg_http_multipart_continue(nc); + return; + } +#endif /* MG_ENABLE_HTTP_STREAMING_MULTIPART */ + /* TODO(alashkin): refactor this ifelseifelseifelseifelse */ if ((req_len < 0 || (req_len == 0 && io->len >= MG_MAX_HTTP_REQUEST_SIZE))) { @@ -5266,10 +5275,6 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) { mg_http_call_endpoint_handler(nc, trigger_ev, hm); #endif mbuf_remove(io, hm->message.len); -#ifdef MG_ENABLE_HTTP_STREAMING_MULTIPART - } else { - mg_http_multipart_begin(nc, hm, req_len); -#endif /* MG_ENABLE_HTTP_STREAMING_MULTIPART */ } } (void) pd; -- GitLab