first merge from 0.9.6.5 (headers management still missing)

This commit is contained in:
roberto@sirius
2010-09-29 08:46:38 +02:00
parent b004168401
commit 46b715fcc3
7 changed files with 54 additions and 18 deletions
+16
View File
@@ -1,5 +1,21 @@
*** september 2010 ***
* 0.9.6.5 [20100929]
- PEP 3333 support
- fix --pythonpath with --wsgi-file
- x-wsgiorg.uwsgi.version renamed to uwsgi.version
* 0.9.6.4 [20100925]
- fix a stupid bug in conditional logging backport
* 0.9.6.3 [20100925]
- fix a buffer overflow in .ini parsing (it throws a glibc error on malloc)
- backport of conditional logging from 0.9.7-dev
- backport of backlog queue monitor from 0.9.7-dev (only Linux)
* 0.9.6.2 [20100915]
- fix a regression in virtual hosting mode
+14
View File
@@ -0,0 +1,14 @@
import uwsgi
def app1(e, sr):
print(e)
sr('200 Ok', [('Content-Type','text/plain')])
return b'i Am a Python 3.x bytestring'
def app2(e, sr):
print(e)
sr('404 Not Found', [('Content-Type','text/plain')])
return b'i Am a Python 3.x Not Found page'
uwsgi.applications = {b'': app1, b'/test': app2}
+1 -5
View File
@@ -471,11 +471,7 @@ void sanitize_args(struct uwsgi_server *uwsgi) {
#endif
#endif
if (uwsgi->wsgi_config) {
uwsgi->single_interpreter = 1 ;
}
if (uwsgi->wsgi_file) {
if (uwsgi->wsgi_config || uwsgi->wsgi_file || uwsgi->eval) {
uwsgi->single_interpreter = 1 ;
}
+4 -3
View File
@@ -1612,20 +1612,21 @@ void init_uwsgi_vars() {
// simulate a pythonhome directive
if (uwsgi.wsgi_req->pyhome_len > 0) {
PyObject *venv_path = PyString_FromStringAndSize(uwsgi.wsgi_req->pyhome, uwsgi.wsgi_req->pyhome_len) ;
PyObject *venv_path = UWSGI_PYFROMSTRINGSIZE(uwsgi.wsgi_req->pyhome, uwsgi.wsgi_req->pyhome_len) ;
#ifdef UWSGI_DEBUG
uwsgi_debug("setting dynamic virtualenv to %s\n", PyString_AsString(venv_path));
uwsgi_debug("setting dynamic virtualenv to %.*s\n", uwsgi.wsgi_req->pyhome_len, uwsgi.wsgi_req->pyhome);
#endif
PyDict_SetItemString(pysys_dict, "prefix", venv_path);
PyDict_SetItemString(pysys_dict, "exec_prefix", venv_path);
venv_version[14] = 0 ;
if (snprintf(venv_version, 15, "/lib/python%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION) == -1) {
if (snprintf(venv_version, 15, "%.*s/lib/python%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION) == -1) {
return ;
}
// check here
PyString_Concat( &venv_path, PyString_FromString(venv_version) );
if ( PyList_Insert(pypath, 0, venv_path) ) {
+2
View File
@@ -272,6 +272,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
#ifdef PYTHREE
#define UWSGI_PYFROMSTRING(x) PyUnicode_FromString(x)
#define UWSGI_PYFROMSTRINGSIZE(x, y) PyUnicode_FromStringAndSize(x, y)
#define PyInt_FromLong PyLong_FromLong
#define PyInt_AsLong PyLong_AsLong
#define PyInt_Check PyLong_Check
@@ -286,6 +287,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
#else
#define UWSGI_PYFROMSTRING(x) PyString_FromString(x)
#define UWSGI_PYFROMSTRINGSIZE(x, y) PyString_FromStringAndSize(x, y)
#endif
#define NL_SIZE 2
+14 -9
View File
@@ -77,8 +77,6 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req
size_t post_remains = wsgi_req->post_cl;
ssize_t post_chunk;
PyObject *zero;
PyObject *pydictkey, *pydictvalue;
static PyObject *uwsgi_version = NULL;
@@ -92,6 +90,9 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req
uwsgi_version = PyString_FromString(UWSGI_VERSION);
}
char *what;
int what_len;
#ifdef UWSGI_ASYNC
if (wsgi_req->async_status == UWSGI_AGAIN) {
// get rid of timeout
@@ -138,19 +139,19 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req
wsgi_req->script_name = "";
if (uwsgi->vhost) {
zero = PyString_FromStringAndSize(wsgi_req->host, wsgi_req->host_len);
PyString_Concat(&zero, PyString_FromString("|"));
PyString_Concat(&zero, PyString_FromStringAndSize(wsgi_req->script_name, wsgi_req->script_name_len));
what = uwsgi_concat3n(wsgi_req->host, wsgi_req->host_len, "|",1, wsgi_req->script_name, wsgi_req->script_name_len);
what_len = wsgi_req->host_len + 1 + wsgi_req->script_name_len ;
#ifdef UWSGI_DEBUG
uwsgi_debug("VirtualHost SCRIPT_NAME=%s\n", PyString_AsString(zero));
uwsgi_debug("VirtualHost SCRIPT_NAME=%s\n", what);
#endif
}
else {
zero = PyString_FromStringAndSize(wsgi_req->script_name, wsgi_req->script_name_len);
what = wsgi_req->script_name;
what_len = wsgi_req->script_name_len ;
}
if ( (wsgi_req->app_id = uwsgi_get_app_id(uwsgi, wsgi_req->script_name, wsgi_req->script_name_len)) == -1) {
if ( (wsgi_req->app_id = uwsgi_get_app_id(uwsgi, what, what_len)) == -1) {
if (wsgi_req->script_name_len > 1 || uwsgi->default_app < 0 || uwsgi->vhost) {
/* unavailable app for this SCRIPT_NAME */
wsgi_req->app_id = -1;
@@ -160,7 +161,6 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req
}
}
Py_DECREF(zero);
}
else {
wsgi_req->app_id = 0;
@@ -233,8 +233,13 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req
uwsgi_debug("%.*s: %.*s\n", wsgi_req->hvec[i].iov_len, wsgi_req->hvec[i].iov_base, wsgi_req->hvec[i+1].iov_len, wsgi_req->hvec[i+1].iov_base);
#endif
*/
#ifdef PYTHREE
pydictkey = PyUnicode_DecodeLatin1(wsgi_req->hvec[i].iov_base, wsgi_req->hvec[i].iov_len, "ignore");
pydictvalue = PyUnicode_DecodeLatin1(wsgi_req->hvec[i + 1].iov_base, wsgi_req->hvec[i + 1].iov_len, "ignore");
#else
pydictkey = PyString_FromStringAndSize(wsgi_req->hvec[i].iov_base, wsgi_req->hvec[i].iov_len);
pydictvalue = PyString_FromStringAndSize(wsgi_req->hvec[i + 1].iov_base, wsgi_req->hvec[i + 1].iov_len);
#endif
PyDict_SetItem(wsgi_req->async_environ, pydictkey, pydictvalue);
Py_DECREF(pydictkey);
Py_DECREF(pydictvalue);
+3 -1
View File
@@ -6,6 +6,8 @@ static char *nl = "\r\n";
static char *h_sep = ": ";
static const char *http_protocol = "HTTP/1.1";
// check here
PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
PyObject *headers, *head;
PyObject *h_key, *h_value;
@@ -20,7 +22,7 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
// is a Web3 response ?
if (PyTuple_Size(args) == 3) {
shift = 1;
shift = 0;
}
head = PyTuple_GetItem(args, 0+shift);