diff --git a/plugins/python/wsgi_headers.c b/plugins/python/wsgi_headers.c index 93aadf73..dd803b35 100644 --- a/plugins/python/wsgi_headers.c +++ b/plugins/python/wsgi_headers.c @@ -114,6 +114,10 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) { wsgi_req->hvec[2].iov_len = NL_SIZE; } + // incref status line + wsgi_req->status_header = head; + Py_INCREF((PyObject *)wsgi_req->status_header); + headers = PyTuple_GetItem(args, 1); if (!headers) { return PyErr_Format(PyExc_TypeError, "start_response() takes at least 2 arguments"); @@ -258,6 +262,8 @@ int uwsgi_python_do_send_headers(struct wsgi_request *wsgi_req) { wsgi_req->headers_sent = 1; + Py_DECREF((PyObject *)wsgi_req->status_header); + if (wsgi_req->write_errors > uwsgi.write_errors_tolerance && !uwsgi.disable_write_exception) { uwsgi_py_write_set_exception(wsgi_req); return -1; diff --git a/uwsgi.h b/uwsgi.h index 85fcdb1d..b8f9d503 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -896,6 +896,7 @@ struct wsgi_request { int do_not_add_to_async_queue; int status; + void *status_header; size_t response_size; ssize_t headers_size;