mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-03 15:38:36 +00:00
fixed python3 headers management
This commit is contained in:
+1
-2
@@ -124,8 +124,8 @@ static int consume_body_for_readline(struct wsgi_request *wsgi_req) {
|
||||
|
||||
// read from post_buffering memory
|
||||
if (uwsgi.post_buffering) {
|
||||
wsgi_req->post_pos += wsgi_req->post_readline_size - wsgi_req->post_readline_watermark;
|
||||
memcpy(wsgi_req->post_readline_buf + wsgi_req->post_readline_watermark, wsgi_req->post_buffering_buf + wsgi_req->post_pos, wsgi_req->post_readline_size - wsgi_req->post_readline_watermark);
|
||||
wsgi_req->post_pos += wsgi_req->post_readline_size - wsgi_req->post_readline_watermark;
|
||||
wsgi_req->post_readline_watermark += wsgi_req->post_readline_size - wsgi_req->post_readline_watermark;
|
||||
return 0;
|
||||
}
|
||||
@@ -347,7 +347,6 @@ char *uwsgi_request_body_read(struct wsgi_request *wsgi_req, ssize_t hint, ssize
|
||||
if (wsgi_req->post_file) {
|
||||
if (fread(wsgi_req->post_read_buf + *rlen, remains, 1, wsgi_req->post_file) != 1) {
|
||||
*rlen = -1;
|
||||
uwsgi_log("%llu\n", remains);
|
||||
uwsgi_error("uwsgi_request_body_read()/fread()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -58,11 +58,12 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
|
||||
char *status_line = NULL;
|
||||
size_t status_line_len = 0;
|
||||
#ifdef PYTHREE
|
||||
PyObject *zero = NULL;
|
||||
PyObject *zero2 = NULL;
|
||||
if (self != Py_None) {
|
||||
PyObject *zero = PyUnicode_AsASCIIString(head);
|
||||
zero = PyUnicode_AsASCIIString(head);
|
||||
status_line = PyBytes_AsString(zero);
|
||||
status_line_len = PyBytes_Size(zero);
|
||||
Py_DECREF(zero);
|
||||
}
|
||||
else {
|
||||
status_line = PyBytes_AsString(head);
|
||||
@@ -73,9 +74,15 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
|
||||
status_line_len = PyString_Size(head);
|
||||
#endif
|
||||
if (uwsgi_response_prepare_headers(wsgi_req, status_line, status_line_len)) {
|
||||
#ifdef PYTHREE
|
||||
Py_DECREF(zero);
|
||||
#endif
|
||||
return PyErr_Format(PyExc_TypeError, "unable to set HTTP status line");
|
||||
}
|
||||
|
||||
#ifdef PYTHREE
|
||||
Py_DECREF(zero);
|
||||
#endif
|
||||
|
||||
headers = PyTuple_GetItem(args, 1);
|
||||
if (!headers) {
|
||||
@@ -125,10 +132,9 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
|
||||
|
||||
#ifdef PYTHREE
|
||||
if (self != Py_None) {
|
||||
PyObject *zero = PyUnicode_AsASCIIString(h_key);
|
||||
zero = PyUnicode_AsASCIIString(h_key);
|
||||
k = PyBytes_AsString(zero);
|
||||
kl = PyBytes_Size(zero);
|
||||
Py_DECREF(zero);
|
||||
}
|
||||
else {
|
||||
k = PyBytes_AsString(h_key);
|
||||
@@ -141,10 +147,9 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
|
||||
|
||||
#ifdef PYTHREE
|
||||
if (self != Py_None) {
|
||||
PyObject *zero = PyUnicode_AsASCIIString(h_value);
|
||||
v = PyBytes_AsString(zero);
|
||||
vl = PyBytes_Size(zero);
|
||||
Py_DECREF(zero);
|
||||
zero2 = PyUnicode_AsASCIIString(h_value);
|
||||
v = PyBytes_AsString(zero2);
|
||||
vl = PyBytes_Size(zero2);
|
||||
}
|
||||
else {
|
||||
v = PyBytes_AsString(h_value);
|
||||
@@ -156,9 +161,18 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
|
||||
#endif
|
||||
|
||||
if (uwsgi_response_add_header(wsgi_req, k, kl, v, vl)) {
|
||||
#ifdef PYTHREE
|
||||
Py_DECREF(zero);
|
||||
Py_DECREF(zero2);
|
||||
#endif
|
||||
return PyErr_Format(PyExc_TypeError, "unable to add header to the response");
|
||||
}
|
||||
|
||||
#ifdef PYTHREE
|
||||
Py_DECREF(zero);
|
||||
Py_DECREF(zero2);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (up.start_response_nodelay) {
|
||||
|
||||
Reference in New Issue
Block a user