diff --git a/plugins/python/wsgi_headers.c b/plugins/python/wsgi_headers.c index 71205b86..10cbf3ad 100644 --- a/plugins/python/wsgi_headers.c +++ b/plugins/python/wsgi_headers.c @@ -253,10 +253,6 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) { int uwsgi_python_do_send_headers(struct wsgi_request *wsgi_req) { - uwsgi_log("- headers = %d\n", ((PyObject *)wsgi_req->headers)->ob_refcnt); - uwsgi_log("- status = %p\n", wsgi_req->status_header); - uwsgi_log("- status = %d\n", ((PyObject *)wsgi_req->status_header)->ob_refcnt); - #ifdef __sun__ int remains = wsgi_req->headers_hvec + 1; int iov_size; diff --git a/plugins/python/wsgi_subhandler.c b/plugins/python/wsgi_subhandler.c index 7f480fe8..fc829dfc 100644 --- a/plugins/python/wsgi_subhandler.c +++ b/plugins/python/wsgi_subhandler.c @@ -187,6 +187,10 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { #else if (wsgi_req->sendfile_obj == wsgi_req->async_result && wsgi_req->sendfile_fd != -1) { #endif + // send the headers if not already sent + if (!wsgi_req->headers_sent && wsgi_req->headers_hvec > 0) { + uwsgi_python_do_send_headers(wsgi_req); + } sf_len = uwsgi_sendfile(wsgi_req); if (sf_len < 1) goto clear; wsgi_req->response_size += sf_len; @@ -274,6 +278,10 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { #ifdef UWSGI_SENDFILE else if (wsgi_req->sendfile_obj == pychunk && wsgi_req->sendfile_fd != -1) { + // send the headers if not already sent + if (!wsgi_req->headers_sent && wsgi_req->headers_hvec > 0) { + uwsgi_python_do_send_headers(wsgi_req); + } sf_len = uwsgi_sendfile(wsgi_req); if (sf_len < 1) goto clear; wsgi_req->response_size += sf_len;