From 732ed3eb67e445aee2e3f612a0b59e81e4cd08c1 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sun, 19 Oct 2014 12:52:11 +0200 Subject: [PATCH] added automatic management of chunked input in http router --- core/emperor.c | 2 +- plugins/http/common.h | 1 + plugins/http/http.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/emperor.c b/core/emperor.c index 07898aea..3f5ccc95 100644 --- a/core/emperor.c +++ b/core/emperor.c @@ -1527,7 +1527,7 @@ static void uwsgi_emperor_spawn_vassal(struct uwsgi_instance *n_ui) { if (uwsgi.emperor_tyrant_initgroups) { char *uidname = NULL; - gid_t gid = NULL; + gid_t gid = n_ui->gid; struct passwd *pw = getpwuid(n_ui->uid); if (pw) { diff --git a/plugins/http/common.h b/plugins/http/common.h index fb46663a..4d994ad5 100644 --- a/plugins/http/common.h +++ b/plugins/http/common.h @@ -50,6 +50,7 @@ struct uwsgi_http { int proto_http; int manage_rtsp; + int chunked_input; }; struct http_session { diff --git a/plugins/http/http.c b/plugins/http/http.c index 19f82623..ea1d02eb 100644 --- a/plugins/http/http.c +++ b/plugins/http/http.c @@ -41,6 +41,7 @@ struct uwsgi_option http_options[] = { {"http-raw-body", no_argument, 0, "blindly send HTTP body to backends (required for WebSockets and Icecast support in backends)", uwsgi_opt_true, &uhttp.raw_body, 0}, {"http-websockets", no_argument, 0, "automatically detect websockets connections and put the session in raw mode", uwsgi_opt_true, &uhttp.websockets, 0}, + {"http-chunked-input", no_argument, 0, "automatically detect chunked input requests and put the session in raw mode", uwsgi_opt_true, &uhttp.chunked_input, 0}, {"http-use-code-string", required_argument, 0, "use code string as hostname->server mapper for the http router", uwsgi_opt_corerouter_cs, &uhttp, 0}, {"http-use-socket", optional_argument, 0, "forward request to the specified uwsgi socket", uwsgi_opt_corerouter_use_socket, &uhttp, 0}, @@ -164,6 +165,11 @@ static int http_header_dumb_check(struct http_session *hr, struct corerouter_pee // in the future we could support chunked requests... else if (!uwsgi_strnicmp("TRANSFER_ENCODING", 17, hh, keylen)) { hr->session.can_keepalive = 0; + if (uhttp.chunked_input) { + if (!uwsgi_strnicmp(val, vallen, "chunked", 7)) { + hr->raw_body = 1; + } + } } else if (!uwsgi_strnicmp("CONNECTION", 10, hh, keylen)) { @@ -261,6 +267,11 @@ static int http_add_uwsgi_header(struct corerouter_peer *peer, char *hh, size_t // in the future we could support chunked requests... else if (!uwsgi_strncmp("TRANSFER_ENCODING", 17, hh, keylen)) { hr->session.can_keepalive = 0; + if (uhttp.chunked_input) { + if (!uwsgi_strnicmp(val, vallen, "chunked", 7)) { + hr->raw_body = 1; + } + } } else if (!uwsgi_strncmp("CONNECTION", 10, hh, keylen)) {