From 4aa17c40fcc520ce38f737b6fb609836f1a0759f Mon Sep 17 00:00:00 2001 From: Unbit Date: Thu, 28 Feb 2013 14:08:15 +0100 Subject: [PATCH] allows building without ssl --- plugins/http/common.h | 2 +- plugins/http/http.c | 12 ++++++++++++ plugins/http/keepalive.c | 10 ++++++++++ plugins/python/uwsgi_pymodule.c | 2 ++ plugins/sslrouter/sslrouter.c | 7 ++++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/plugins/http/common.h b/plugins/http/common.h index ab283c65..26d37a9f 100644 --- a/plugins/http/common.h +++ b/plugins/http/common.h @@ -25,8 +25,8 @@ struct uwsgi_http { int auto_chunked; int auto_gzip; -#ifdef UWSGI_SSL int websockets; +#ifdef UWSGI_SSL char *https_session_context; int https_export_cert; #endif diff --git a/plugins/http/http.c b/plugins/http/http.c index fa938e03..0292754e 100644 --- a/plugins/http/http.c +++ b/plugins/http/http.c @@ -456,8 +456,10 @@ ssize_t hr_instance_read(struct corerouter_peer *peer) { if (hr->session.can_keepalive) { peer->session->main_peer->disabled = 0; hr->rnrn = 0; +#ifdef UWSGI_ZLIB hr->can_gzip = 0; hr->has_gzip = 0; +#endif if (uhttp.keepalive > 1) { int orig_timeout = peer->session->corerouter->socket_timeout; peer->session->corerouter->socket_timeout = uhttp.keepalive; @@ -465,11 +467,16 @@ ssize_t hr_instance_read(struct corerouter_peer *peer) { peer->session->corerouter->socket_timeout = orig_timeout; } } +#ifdef UWSGI_ZLIB if (hr->force_chunked || hr->force_gzip) { +#else + if (hr->force_chunked) { +#endif hr->force_chunked = 0; if (!hr->last_chunked) { hr->last_chunked = uwsgi_buffer_new(5); } +#ifdef UWSGI_ZLIB if (hr->force_gzip) { hr->force_gzip = 0; size_t zlen = 0; @@ -484,6 +491,7 @@ ssize_t hr_instance_read(struct corerouter_peer *peer) { if (uwsgi_buffer_u32le(hr->last_chunked, hr->gzip_size)) return -1; if (uwsgi_buffer_append(hr->last_chunked, "\r\n", 2)) return -1; } +#endif if (uwsgi_buffer_append(hr->last_chunked, "0\r\n\r\n", 5)) return -1; peer->session->main_peer->out = hr->last_chunked; peer->session->main_peer->out_pos = 0; @@ -499,7 +507,11 @@ ssize_t hr_instance_read(struct corerouter_peer *peer) { } // need to parse response headers +#ifdef UWSGI_ZLIB if (hr->session.can_keepalive || hr->can_gzip) { +#else + if (hr->session.can_keepalive) { +#endif if (peer->r_parser_status != 4) { int ret = hr_check_response_keepalive(peer); if (ret < 0) return -1; diff --git a/plugins/http/keepalive.c b/plugins/http/keepalive.c index cbb76034..1396521a 100644 --- a/plugins/http/keepalive.c +++ b/plugins/http/keepalive.c @@ -67,7 +67,11 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t if (!colon) return -1; // security check if (colon+2 >= buf+len) return -1; +#ifdef UWSGI_ZLIB if (hr->session.can_keepalive || (uhttp.auto_gzip && hr->can_gzip)) { +#else + if (hr->session.can_keepalive) { +#endif if (!uwsgi_strnicmp(key, colon-key, "Connection", 10)) { if (!uwsgi_strnicmp(colon+2, h_len-((colon-key)+2), "close", 5)) { goto end; @@ -83,6 +87,7 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t has_size = 1; } } +#ifdef UWSGI_ZLIB if (uhttp.auto_gzip && hr->can_gzip) { if (!uwsgi_strnicmp(key, colon-key, "Content-Encoding", 16)) { hr->can_gzip = 0; @@ -93,6 +98,7 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t } } } +#endif key = NULL; h_len = 0; } @@ -109,6 +115,7 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t } if (!has_size) { +#ifdef UWSGI_ZLIB if (hr->has_gzip) { hr->force_gzip = 1; if (uwsgi_deflate_init(&hr->z, NULL, 0)) { @@ -148,6 +155,9 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t hr->session.can_keepalive = hr->session.can_keepalive; } else if (hr->session.can_keepalive) { +#else + if (hr->session.can_keepalive) { +#endif if (uhttp.auto_chunked) { char cr = buf[len-2]; char nl = buf[len-1]; diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index cc73fa8f..4c667f4f 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -437,6 +437,7 @@ PyObject *py_uwsgi_signal_registered(PyObject * self, PyObject * args) { return Py_None; } +#ifdef UWSGI_SSL PyObject *py_uwsgi_i_am_the_lord(PyObject * self, PyObject * args) { char *legion_name = NULL; @@ -452,6 +453,7 @@ PyObject *py_uwsgi_i_am_the_lord(PyObject * self, PyObject * args) { Py_INCREF(Py_False); return Py_False; } +#endif PyObject *py_uwsgi_register_signal(PyObject * self, PyObject * args) { diff --git a/plugins/sslrouter/sslrouter.c b/plugins/sslrouter/sslrouter.c index 0c1b4d1b..7d137115 100644 --- a/plugins/sslrouter/sslrouter.c +++ b/plugins/sslrouter/sslrouter.c @@ -1,3 +1,5 @@ +#include + #ifdef UWSGI_SSL /* @@ -6,7 +8,6 @@ */ -#include #include "../corerouter/cr.h" extern struct uwsgi_server uwsgi; @@ -378,4 +379,8 @@ struct uwsgi_plugin sslrouter_plugin = { .on_load = sslrouter_setup }; +#else +struct uwsgi_plugin sslrouter_plugin = { + .name = "sslrouter", +}; #endif