diff --git a/plugins/python/wsgi_handlers.c b/plugins/python/wsgi_handlers.c index fa2a8076..2b91ef14 100644 --- a/plugins/python/wsgi_handlers.c +++ b/plugins/python/wsgi_handlers.c @@ -280,7 +280,7 @@ PyObject *py_uwsgi_write(PyObject * self, PyObject * args) { UWSGI_GET_GIL // this is a special case for the write callable // no need to honout write-errors-exception-only - if (wsgi_req->write_errors > 0) { + if (wsgi_req->write_errors > uwsgi.write_errors_tolerance) { uwsgi_py_write_set_exception(wsgi_req); return NULL; } diff --git a/plugins/python/wsgi_headers.c b/plugins/python/wsgi_headers.c index afd7fab2..d7ed9285 100644 --- a/plugins/python/wsgi_headers.c +++ b/plugins/python/wsgi_headers.c @@ -201,6 +201,11 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) { UWSGI_GET_GIL #endif + if (wsgi_req->write_errors > uwsgi.write_errors_tolerance) { + uwsgi_py_write_set_exception(wsgi_req); + return NULL; + } + //uwsgi_log("%d %p\n", wsgi_req->poll.fd, up.wsgi_writeout); Py_INCREF(up.wsgi_writeout); diff --git a/proto/zeromq.c b/proto/zeromq.c index 0ff46e23..178c771a 100644 --- a/proto/zeromq.c +++ b/proto/zeromq.c @@ -96,6 +96,17 @@ static int uwsgi_mongrel2_json_parse(json_t * root, struct wsgi_request *wsgi_re } } + if ((json_val = uwsgi_mongrel2_json_get_string(root, "x-forwarded-for"))) { + char *colon = strchr(json_val, ','); + if (colon) { + wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "REMOTE_ADDR", 11, colon + 1, (colon + 1) - json_val); + } + else { + wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "REMOTE_ADDR", 11, json_val, strlen(json_val)); + } + } + + if ((json_val = uwsgi_mongrel2_json_get_string(root, "content-length"))) { wsgi_req->post_cl = atoi(json_val); } @@ -205,6 +216,15 @@ static int uwsgi_mongrel2_tnetstring_parse(struct wsgi_request *wsgi_req, char * async_upload += 2; free(post_filename); } + else if (!uwsgi_strncmp("x-forwarded-for", 15, key, keylen)) { + char *colon = strchr(val, ','); + if (colon) { + wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "REMOTE_ADDR", 11, colon + 1, (colon + 1) - val); + } + else { + wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "REMOTE_ADDR", 11, val, vallen); + } + } else if (!uwsgi_strncmp("x-mongrel2-upload-start", 23, key, keylen)) { async_upload += 1; }