the http router is now websocket friendly

This commit is contained in:
roberto@quantal64
2012-06-17 18:06:53 +02:00
parent e796a57f14
commit 8ddeed80cf
2 changed files with 14 additions and 0 deletions
+8
View File
@@ -28,6 +28,9 @@ struct uwsgi_http {
uint8_t modifier1;
struct uwsgi_string_list *http_vars;
int manage_expect;
int raw_body;
int keepalive;
#ifdef UWSGI_SSL
int https_export_cert;
@@ -128,6 +131,8 @@ struct uwsgi_option http_options[] = {
{"http-manage-expect", no_argument, 0, "manage the Expect HTTP request header", uwsgi_opt_true, &uhttp.manage_expect, 0},
{"http-keepalive", no_argument, 0, "support HTTP keepalive (non-pipelined) requests (requires backend support)", uwsgi_opt_true, &uhttp.keepalive, 0},
{"http-raw-body", no_argument, 0, "blindly send HTTP body to backends (required for WebSockets and Icecast support)", uwsgi_opt_true, &uhttp.raw_body, 0},
{"http-use-code-string", required_argument, 0, "use code string as hostname->server mapper for the http router", uwsgi_opt_corerouter_cs, &uhttp, 0},
{"http-use-socket", optional_argument, 0, "forward request to the specified uwsgi socket", uwsgi_opt_corerouter_use_socket, &uhttp, 0},
{"http-gracetime", required_argument, 0, "retry connections to dead static nodes after the specified amount of seconds", uwsgi_opt_set_int, &uhttp.cr.static_node_gracetime, 0},
@@ -806,6 +811,8 @@ To have a reliable implementation, we need to reset a bunch of values
break;
}
if (cs->post_cl == 0 && uhttp.raw_body) goto raw;
// avoid pipelined input
if (hs->received_body >= cs->post_cl) {
break;
@@ -816,6 +823,7 @@ To have a reliable implementation, we need to reset a bunch of values
len = cs->post_cl - hs->received_body;
}
raw:
len = send(cs->instance_fd, bbuf, len, 0);
if (len <= 0) {
+6
View File
@@ -997,6 +997,11 @@ PyObject *py_uwsgi_unlock(PyObject * self, PyObject * args) {
return Py_None;
}
PyObject *py_uwsgi_connection_fd(PyObject * self, PyObject * args) {
struct wsgi_request *wsgi_req = current_wsgi_req();
return PyInt_FromLong(wsgi_req->poll.fd);
}
PyObject *py_uwsgi_embedded_data(PyObject * self, PyObject * args) {
char *name;
@@ -3130,6 +3135,7 @@ static PyMethodDef uwsgi_advanced_methods[] = {
#endif
{"connect", py_uwsgi_connect, METH_VARARGS, ""},
{"connection_fd", py_uwsgi_connection_fd, METH_VARARGS, ""},
{"is_connected", py_uwsgi_is_connected, METH_VARARGS, ""},
{"send", py_uwsgi_send, METH_VARARGS, ""},
{"recv", py_uwsgi_recv, METH_VARARGS, ""},