mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 21:51:30 +00:00
completed port of the python plugin to the new writing api
This commit is contained in:
@@ -218,7 +218,9 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
|
||||
goto clear;
|
||||
}
|
||||
|
||||
uwsgi_response_prepare_headers(wsgi_req, sc, 3);
|
||||
if (uwsgi_response_prepare_headers(wsgi_req, sc, 3)) {
|
||||
uwsgi_log("unable to prepare response headers\n");
|
||||
}
|
||||
|
||||
PyObject *hhkey, *hhvalue;
|
||||
#ifdef UWSGI_PYTHON_OLD
|
||||
@@ -237,12 +239,12 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
|
||||
for(i=0;i<PyList_Size(hhvalue);i++) {
|
||||
PyObject *item = PyList_GetItem(hhvalue, i);
|
||||
if (PyString_Check(item)) {
|
||||
uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(item), PyString_Size(item));
|
||||
if (uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(item), PyString_Size(item))) goto clear;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PyString_Check(hhvalue)) {
|
||||
uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(hhvalue), PyString_Size(hhvalue));
|
||||
if (uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(hhvalue), PyString_Size(hhvalue))) goto clear;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +254,9 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
|
||||
UWSGI_RELEASE_GIL
|
||||
uwsgi_response_write_body_do(wsgi_req, PyString_AsString(wsgi_req->async_placeholder), PyString_Size(wsgi_req->async_placeholder));
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
}
|
||||
goto clear;
|
||||
}
|
||||
#ifdef PYTHREE
|
||||
@@ -263,6 +268,9 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
|
||||
UWSGI_RELEASE_GIL
|
||||
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, 0, 0);
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
}
|
||||
goto clear;
|
||||
}
|
||||
|
||||
@@ -301,6 +309,11 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
|
||||
UWSGI_RELEASE_GIL
|
||||
uwsgi_response_write_body_do(wsgi_req, PyString_AsString(pychunk), PyString_Size(pychunk));
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
Py_DECREF(pychunk);
|
||||
goto clear;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -887,7 +887,6 @@ PyObject *py_uwsgi_advanced_sendfile(PyObject * self, PyObject * args) {
|
||||
UWSGI_RELEASE_GIL
|
||||
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, wsgi_req->sendfile_fd_pos, wsgi_req->sendfile_fd_size);
|
||||
UWSGI_GET_GIL
|
||||
|
||||
// revert to old values
|
||||
wsgi_req->sendfile_fd = tmp_fd;
|
||||
wsgi_req->sendfile_fd_size = tmp_filesize;
|
||||
@@ -896,6 +895,12 @@ PyObject *py_uwsgi_advanced_sendfile(PyObject * self, PyObject * args) {
|
||||
|
||||
|
||||
close(fd);
|
||||
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_True);
|
||||
return Py_True;
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) {
|
||||
char *content = PyString_AsString(wsgi_req->async_placeholder);
|
||||
size_t content_len = PyString_Size(wsgi_req->async_placeholder);
|
||||
UWSGI_RELEASE_GIL
|
||||
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
|
||||
uwsgi_response_write_body_do(wsgi_req, content, content_len);
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
@@ -213,7 +213,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) {
|
||||
char *content = PyString_AsString(pychunk);
|
||||
size_t content_len = PyString_Size(pychunk);
|
||||
UWSGI_RELEASE_GIL
|
||||
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
|
||||
uwsgi_response_write_body_do(wsgi_req, content, content_len);
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
|
||||
@@ -498,7 +498,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
|
||||
// LOCK THIS PART
|
||||
|
||||
uwsgi_500(wsgi_req);
|
||||
uwsgi_response_write_headers_do(wsgi_req);
|
||||
if (uwsgi_response_write_headers_do(wsgi_req)) goto clear;
|
||||
|
||||
/*
|
||||
sorry that is a hack to avoid the rewrite of PyErr_Print
|
||||
|
||||
@@ -173,6 +173,9 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
|
||||
UWSGI_RELEASE_GIL
|
||||
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, 0, 0);
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
}
|
||||
goto clear;
|
||||
}
|
||||
|
||||
@@ -228,6 +231,11 @@ exception:
|
||||
UWSGI_RELEASE_GIL
|
||||
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, 0, 0);
|
||||
UWSGI_GET_GIL
|
||||
uwsgi_py_check_write_errors {
|
||||
uwsgi_py_write_exception(wsgi_req);
|
||||
Py_DECREF(pychunk);
|
||||
goto clear;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user