Skip to content

Commit

Permalink
Allow setting the response headers buffer limit.
Browse files Browse the repository at this point in the history
Default size is UMAX16 (65536). This should allow for setting larger/smaller.
  • Loading branch information
funkybob authored and unbit committed Sep 19, 2017
1 parent a664237 commit 123feae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"config-py", no_argument, 0, "dump the uwsgiconfig.py used for building the core (useful for building external plugins)", uwsgi_opt_config_py, NULL, UWSGI_OPT_IMMEDIATE},
{"build-plugin", required_argument, 0, "build a uWSGI plugin for the current binary", uwsgi_opt_build_plugin, NULL, UWSGI_OPT_IMMEDIATE},
{"version", no_argument, 0, "print uWSGI version", uwsgi_opt_print, UWSGI_VERSION, 0},
{"response-headers-limit", required_argument, 0, "set response header maximum size (default: 64k)", uwsgi_opt_set_int, &uwsgi.response_header_limit, 0},
{0, 0, 0, 0, 0, 0, 0}
};

Expand Down Expand Up @@ -2257,6 +2258,9 @@ void uwsgi_setup(int argc, char *argv[], char *envp[]) {
#endif
uwsgi.binary_path = uwsgi_get_binary_path(argv[0]);

if(uwsgi.response_header_limit == 0)
uwsgi.response_header_limit = UMAX16;

// ok we can now safely play with argv and environ
fixup_argv_and_environ(argc, argv, environ, envp);

Expand Down
4 changes: 2 additions & 2 deletions core/writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int uwsgi_response_prepare_headers(struct wsgi_request *wsgi_req, char *status,

if (!wsgi_req->headers) {
wsgi_req->headers = uwsgi_buffer_new(uwsgi.page_size);
wsgi_req->headers->limit = UMAX16;
wsgi_req->headers->limit = uwsgi.response_header_limit;
}

// reset the buffer (could be useful for rollbacks...)
Expand Down Expand Up @@ -156,7 +156,7 @@ static int uwsgi_response_add_header_do(struct wsgi_request *wsgi_req, char *key

if (!wsgi_req->headers) {
wsgi_req->headers = uwsgi_buffer_new(uwsgi.page_size);
wsgi_req->headers->limit = UMAX16;
wsgi_req->headers->limit = uwsgi.response_header_limit;
}

struct uwsgi_buffer *hh = wsgi_req->socket->proto_add_header(wsgi_req, key, key_len, value, value_len);
Expand Down
2 changes: 2 additions & 0 deletions uwsgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2897,6 +2897,8 @@ struct uwsgi_server {
#ifdef UWSGI_SSL
int ssl_verify_depth;
#endif

size_t response_header_limit;
};

struct uwsgi_rpc {
Expand Down

0 comments on commit 123feae

Please sign in to comment.