aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-06-01 16:00:42 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-06-01 16:00:42 +0000
commit670cdbba610edd0f15e9a8b0a1669d853722da3c (patch)
tree52981fdf58400d8a1b73c91fef2cce1c5a490c22
parent6d7beea1ce593f1def4dece117c4bffea973991f (diff)
downloadnginx-670cdbba610edd0f15e9a8b0a1669d853722da3c.tar.gz
nginx-670cdbba610edd0f15e9a8b0a1669d853722da3c.zip
fix style, some names, and building by MSVC8
-rw-r--r--src/http/modules/ngx_http_uwsgi_module.c1144
1 files changed, 555 insertions, 589 deletions
diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c
index 4ac43692e..3cc67e55e 100644
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -23,11 +23,10 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
-
-
-
+ *
+ *
+ *
* heavily based on Manlio's mod_scgi, mod_fastcgi and mod_proxy of nginx 0.7.x
-
*/
@@ -35,38 +34,41 @@
#include <ngx_core.h>
#include <ngx_http.h>
+
#define NGX_HTTP_UWSGI_TEMP_PATH "uwsgi_temp"
-typedef struct {
- ngx_http_upstream_conf_t upstream;
- ngx_array_t *flushes;
- ngx_array_t *params_len;
- ngx_array_t *params;
- ngx_array_t *params_source;
+typedef struct {
+ ngx_http_upstream_conf_t upstream;
- ngx_array_t *uwsgi_lengths;
- ngx_array_t *uwsgi_values;
+ ngx_array_t *flushes;
+ ngx_array_t *params_len;
+ ngx_array_t *params;
+ ngx_array_t *params_source;
- ngx_str_t uwsgi_string ;
+ ngx_array_t *uwsgi_lengths;
+ ngx_array_t *uwsgi_values;
- u_char modifier1;
- u_char modifier2;
+ ngx_str_t uwsgi_string ;
+ u_char modifier1;
+ u_char modifier2;
} ngx_http_uwsgi_loc_conf_t;
typedef struct {
- ngx_uint_t status;
- ngx_uint_t status_count;
- u_char *status_start;
- u_char *status_end;
+ ngx_uint_t status;
+ ngx_uint_t status_count;
+ u_char *status_start;
+ u_char *status_end;
} ngx_http_uwsgi_ctx_t;
-#define NGX_HTTP_XCGI_PARSE_NO_HEADER 20
+
+#define NGX_HTTP_UWSGI_PARSE_NO_HEADER 20
+
#ifndef NGX_HAVE_LITTLE_ENDIAN
static uint16_t
-uwsgi_swap16 (uint16_t x)
+uwsgi_swap16(uint16_t x)
{
return (uint16_t) ((x & 0xff) << 8 | (x & 0xff00) >> 8);
}
@@ -74,54 +76,53 @@ uwsgi_swap16 (uint16_t x)
-static ngx_int_t ngx_http_uwsgi_eval (ngx_http_request_t * r,
- ngx_http_uwsgi_loc_conf_t * uwcf);
-static ngx_int_t ngx_http_uwsgi_create_request (ngx_http_request_t * r);
-static ngx_int_t ngx_http_uwsgi_reinit_request (ngx_http_request_t * r);
-static ngx_int_t ngx_http_uwsgi_process_status_line (ngx_http_request_t * r);
-static ngx_int_t ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
- ngx_http_uwsgi_ctx_t *
- ctx);
-static ngx_int_t ngx_http_uwsgi_process_header (ngx_http_request_t * r);
-static ngx_int_t ngx_http_uwsgi_process_header (ngx_http_request_t * r);
-static void ngx_http_uwsgi_abort_request (ngx_http_request_t * r);
-static void ngx_http_uwsgi_finalize_request (ngx_http_request_t * r,
- ngx_int_t rc);
+static ngx_int_t ngx_http_uwsgi_eval(ngx_http_request_t *r,
+ ngx_http_uwsgi_loc_conf_t *uwcf);
+static ngx_int_t ngx_http_uwsgi_create_request(ngx_http_request_t *r);
+static ngx_int_t ngx_http_uwsgi_reinit_request(ngx_http_request_t *r);
+static ngx_int_t ngx_http_uwsgi_process_status_line(ngx_http_request_t *r);
+static ngx_int_t ngx_http_uwsgi_parse_status_line(ngx_http_request_t *r,
+ ngx_http_uwsgi_ctx_t *ctx);
+static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
+static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
+static void ngx_http_uwsgi_abort_request(ngx_http_request_t *r);
+static void ngx_http_uwsgi_finalize_request(ngx_http_request_t *r,
+ ngx_int_t rc);
-static char *ngx_http_uwsgi_modifier1 (ngx_conf_t * cf, ngx_command_t * cmd,
- void *conf);
+static char *ngx_http_uwsgi_modifier1(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
-static char *ngx_http_uwsgi_modifier2 (ngx_conf_t * cf, ngx_command_t * cmd,
- void *conf);
+static char *ngx_http_uwsgi_modifier2(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
-static ngx_int_t ngx_http_uwsgi_add_variables (ngx_conf_t * cf);
-static void *ngx_http_uwsgi_create_loc_conf (ngx_conf_t * cf);
-static char *ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf,
- void *parent, void *child);
+static ngx_int_t ngx_http_uwsgi_add_variables(ngx_conf_t *cf);
+static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf);
+static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
+ void *child);
-static char *ngx_http_uwsgi_pass (ngx_conf_t * cf, ngx_command_t * cmd,
- void *conf);
+static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
static ngx_conf_bitmask_t ngx_http_uwsgi_next_upstream_masks[] = {
- {ngx_string ("error"), NGX_HTTP_UPSTREAM_FT_ERROR},
- {ngx_string ("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT},
- {ngx_string ("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER},
- {ngx_string ("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500},
- {ngx_string ("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503},
- {ngx_string ("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404},
- {ngx_string ("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING},
- {ngx_string ("off"), NGX_HTTP_UPSTREAM_FT_OFF},
- {ngx_null_string, 0}
+ { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
+ { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
+ { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
+ { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
+ { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
+ { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
+ { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
+ { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
+ { ngx_null_string, 0 }
};
static ngx_conf_bitmask_t ngx_http_uwsgi_ignore_headers_masks[] = {
- {ngx_string ("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT},
- {ngx_string ("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES},
- {ngx_string ("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES},
- {ngx_string ("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL},
- {ngx_null_string, 0}
+ { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT },
+ { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES },
+ { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES },
+ { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL },
+ { ngx_null_string, 0 }
};
@@ -130,268 +131,247 @@ ngx_module_t ngx_http_uwsgi_module;
static ngx_command_t ngx_http_uwsgi_commands[] = {
- {ngx_string ("uwsgi_pass"),
- NGX_HTTP_LOC_CONF | NGX_HTTP_LIF_CONF | NGX_CONF_TAKE1,
- ngx_http_uwsgi_pass,
- NGX_HTTP_LOC_CONF_OFFSET,
- 0,
- NULL},
-
- {ngx_string ("uwsgi_modifier1"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_http_uwsgi_modifier1,
- NGX_HTTP_LOC_CONF_OFFSET,
- 0,
- NULL},
-
- {ngx_string ("uwsgi_modifier2"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_http_uwsgi_modifier2,
- NGX_HTTP_LOC_CONF_OFFSET,
- 0,
- NULL},
-
- {ngx_string ("uwsgi_ignore_client_abort"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_FLAG,
- ngx_conf_set_flag_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.ignore_client_abort),
- NULL},
-
- {ngx_string ("uwsgi_connect_timeout"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.connect_timeout),
- NULL},
-
- {ngx_string ("uwsgi_send_timeout"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.send_timeout),
- NULL},
-
- {ngx_string ("uwsgi_buffer_size"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.buffer_size),
- NULL},
-
- {ngx_string ("uwsgi_pass_request_headers"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_FLAG,
- ngx_conf_set_flag_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.pass_request_headers),
- NULL},
-
- {ngx_string ("uwsgi_pass_request_body"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_FLAG,
- ngx_conf_set_flag_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.pass_request_body),
- NULL},
-
- {ngx_string ("uwsgi_intercept_errors"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_FLAG,
- ngx_conf_set_flag_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.intercept_errors),
- NULL},
-
- {ngx_string ("uwsgi_read_timeout"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.read_timeout),
- NULL},
-
- {ngx_string ("uwsgi_buffers"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE2,
- ngx_conf_set_bufs_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.bufs),
- NULL},
-
- {ngx_string ("uwsgi_busy_buffers_size"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.busy_buffers_size_conf),
- NULL},
-
- {ngx_string ("uwsgi_temp_path"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1234,
- ngx_conf_set_path_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.temp_path),
- NULL},
-
- {ngx_string ("uwsgi_max_temp_file_size"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.max_temp_file_size_conf),
- NULL},
-
- {ngx_string ("uwsgi_temp_file_write_size"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.temp_file_write_size_conf),
- NULL},
-
- {ngx_string ("uwsgi_next_upstream"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_1MORE,
- ngx_conf_set_bitmask_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.next_upstream),
- &ngx_http_uwsgi_next_upstream_masks},
-
- {ngx_string ("uwsgi_param"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE2,
- ngx_conf_set_keyval_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, params_source),
- NULL},
+ { ngx_string("uwsgi_pass"),
+ NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
+ ngx_http_uwsgi_pass,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("uwsgi_modifier1"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_uwsgi_modifier1,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("uwsgi_modifier2"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_uwsgi_modifier2,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("uwsgi_ignore_client_abort"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ignore_client_abort),
+ NULL },
+
+ { ngx_string("uwsgi_connect_timeout"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.connect_timeout),
+ NULL },
+
+ { ngx_string("uwsgi_send_timeout"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.send_timeout),
+ NULL },
+
+ { ngx_string("uwsgi_buffer_size"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffer_size),
+ NULL },
+
+ { ngx_string("uwsgi_pass_request_headers"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_request_headers),
+ NULL },
+
+ { ngx_string("uwsgi_pass_request_body"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_request_body),
+ NULL },
+
+ { ngx_string("uwsgi_intercept_errors"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.intercept_errors),
+ NULL },
+
+ { ngx_string("uwsgi_read_timeout"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.read_timeout),
+ NULL },
+
+ { ngx_string("uwsgi_buffers"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
+ ngx_conf_set_bufs_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.bufs),
+ NULL },
+
+ { ngx_string("uwsgi_busy_buffers_size"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.busy_buffers_size_conf),
+ NULL },
+
+ { ngx_string("uwsgi_temp_path"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
+ ngx_conf_set_path_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.temp_path),
+ NULL },
+
+ { ngx_string("uwsgi_max_temp_file_size"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.max_temp_file_size_conf),
+ NULL },
+
+ { ngx_string("uwsgi_temp_file_write_size"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.temp_file_write_size_conf),
+ NULL },
+
+ { ngx_string("uwsgi_next_upstream"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
+ ngx_conf_set_bitmask_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream),
+ &ngx_http_uwsgi_next_upstream_masks },
+
+ { ngx_string("uwsgi_param"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
+ ngx_conf_set_keyval_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, params_source),
+ NULL },
{ ngx_string("uwsgi_string"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_TAKE1,
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, uwsgi_string),
NULL },
- {ngx_string ("uwsgi_pass_header"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_FLAG,
- ngx_conf_set_str_array_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.pass_headers),
- NULL},
-
- {ngx_string ("uwsgi_hide_header"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_FLAG,
- ngx_conf_set_str_array_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.hide_headers),
- NULL},
-
- {ngx_string ("uwsgi_ignore_headers"),
- NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF |
- NGX_CONF_1MORE,
- ngx_conf_set_bitmask_slot,
- NGX_HTTP_LOC_CONF_OFFSET,
- offsetof (ngx_http_uwsgi_loc_conf_t, upstream.ignore_headers),
- &ngx_http_uwsgi_ignore_headers_masks},
-
- ngx_null_command
+ { ngx_string("uwsgi_pass_header"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_str_array_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_headers),
+ NULL },
+
+ { ngx_string("uwsgi_hide_header"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_str_array_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.hide_headers),
+ NULL },
+
+ { ngx_string("uwsgi_ignore_headers"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
+ ngx_conf_set_bitmask_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ignore_headers),
+ &ngx_http_uwsgi_ignore_headers_masks },
+
+ ngx_null_command
};
static ngx_http_module_t ngx_http_uwsgi_module_ctx = {
- ngx_http_uwsgi_add_variables, /* preconfiguration */
- NULL, /* postconfiguration */
+ ngx_http_uwsgi_add_variables, /* preconfiguration */
+ NULL, /* postconfiguration */
- NULL, /* create main configuration */
- NULL, /* init main configuration */
+ NULL, /* create main configuration */
+ NULL, /* init main configuration */
- NULL, /* create server configuration */
- NULL, /* merge server configuration */
+ NULL, /* create server configuration */
+ NULL, /* merge server configuration */
ngx_http_uwsgi_create_loc_conf, /* create location configuration */
- ngx_http_uwsgi_merge_loc_conf /* merge location configuration */
+ ngx_http_uwsgi_merge_loc_conf /* merge location configuration */
};
ngx_module_t ngx_http_uwsgi_module = {
NGX_MODULE_V1,
- &ngx_http_uwsgi_module_ctx, /* module context */
- ngx_http_uwsgi_commands, /* module directives */
- NGX_HTTP_MODULE, /* module type */
- NULL, /* init master */
- NULL, /* init module */
- NULL, /* init process */
- NULL, /* init thread */
- NULL, /* exit thread */
- NULL, /* exit process */
- NULL, /* exit master */
+ &ngx_http_uwsgi_module_ctx, /* module context */
+ ngx_http_uwsgi_commands, /* module directives */
+ NGX_HTTP_MODULE, /* module type */
+ NULL, /* init master */
+ NULL, /* init module */
+ NULL, /* init process */
+ NULL, /* init thread */
+ NULL, /* exit thread */
+ NULL, /* exit process */
+ NULL, /* exit master */
NGX_MODULE_V1_PADDING
};
static ngx_http_variable_t ngx_http_uwsgi_vars[] = {
- {ngx_null_string, NULL, NULL, 0, 0, 0}
+ { ngx_null_string, NULL, NULL, 0, 0, 0 }
};
static ngx_str_t ngx_http_uwsgi_hide_headers[] = {
- ngx_string ("Status"),
- ngx_string ("X-Accel-Expires"),
- ngx_string ("X-Accel-Redirect"),
- ngx_string ("X-Accel-Limit-Rate"),
- ngx_string ("X-Accel-Buffering"),
- ngx_string ("X-Accel-Charset"),
+ ngx_string("Status"),
+ ngx_string("X-Accel-Expires"),
+ ngx_string("X-Accel-Redirect"),
+ ngx_string("X-Accel-Limit-Rate"),
+ ngx_string("X-Accel-Buffering"),
+ ngx_string("X-Accel-Charset"),
ngx_null_string
};
static ngx_path_init_t ngx_http_uwsgi_temp_path = {
- ngx_string (NGX_HTTP_UWSGI_TEMP_PATH), {1, 2, 0}
+ ngx_string(NGX_HTTP_UWSGI_TEMP_PATH), { 1, 2, 0 }
};
static ngx_int_t
-ngx_http_uwsgi_handler (ngx_http_request_t * r)
+ngx_http_uwsgi_handler(ngx_http_request_t *r)
{
- ngx_int_t rc;
- ngx_http_upstream_t *u;
- ngx_http_uwsgi_ctx_t *f;
- ngx_http_uwsgi_loc_conf_t *uwcf;
+ ngx_int_t rc;
+ ngx_http_upstream_t *u;
+ ngx_http_uwsgi_ctx_t *ctx;
+ ngx_http_uwsgi_loc_conf_t *uwcf;
if (r->subrequest_in_memory) {
- ngx_log_error (NGX_LOG_ALERT, r->connection->log, 0,
- "ngx_http_uwsgi_module does not support "
- "subrequest in memory");
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+ "ngx_http_uwsgi_module does not support "
+ "subrequests in memory");
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- if (ngx_http_upstream_create (r) != NGX_OK) {
+ if (ngx_http_upstream_create(r) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- f = ngx_pcalloc (r->pool, sizeof (ngx_http_uwsgi_ctx_t));
- if (f == NULL) {
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_uwsgi_ctx_t));
+ if (ctx == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- ngx_http_set_ctx (r, f, ngx_http_uwsgi_module);
+ ngx_http_set_ctx(r, ctx, ngx_http_uwsgi_module);
- uwcf = ngx_http_get_module_loc_conf (r, ngx_http_uwsgi_module);
+ uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
if (uwcf->uwsgi_lengths) {
- if (ngx_http_uwsgi_eval (r, uwcf) != NGX_OK) {
+ if (ngx_http_uwsgi_eval(r, uwcf) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
}
@@ -401,7 +381,7 @@ ngx_http_uwsgi_handler (ngx_http_request_t * r)
u->schema.len = sizeof ("uwsgi://") - 1;
u->schema.data = (u_char *) "uwsgi://";
- u->output.tag = (ngx_buf_tag_t) & ngx_http_uwsgi_module;
+ u->output.tag = (ngx_buf_tag_t) &ngx_http_uwsgi_module;
u->conf = &uwcf->upstream;
@@ -413,7 +393,7 @@ ngx_http_uwsgi_handler (ngx_http_request_t * r)
u->buffering = 1;
- u->pipe = ngx_pcalloc (r->pool, sizeof (ngx_event_pipe_t));
+ u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
if (u->pipe == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
@@ -421,7 +401,7 @@ ngx_http_uwsgi_handler (ngx_http_request_t * r)
u->pipe->input_filter = ngx_event_pipe_copy_input_filter;
u->pipe->input_ctx = r;
- rc = ngx_http_read_client_request_body (r, ngx_http_upstream_init);
+ rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
return rc;
@@ -432,37 +412,38 @@ ngx_http_uwsgi_handler (ngx_http_request_t * r)
static ngx_int_t
-ngx_http_uwsgi_eval (ngx_http_request_t * r, ngx_http_uwsgi_loc_conf_t * uwcf)
+ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf)
{
- ngx_url_t u;
+ ngx_url_t u;
- ngx_memzero (&u, sizeof (ngx_url_t));
+ ngx_memzero(&u, sizeof(ngx_url_t));
- if (ngx_http_script_run (r, &u.url, uwcf->uwsgi_lengths->elts, 0,
- uwcf->uwsgi_values->elts) == NULL) {
+ if (ngx_http_script_run(r, &u.url, uwcf->uwsgi_lengths->elts, 0,
+ uwcf->uwsgi_values->elts)
+ == NULL)
+ {
return NGX_ERROR;
}
u.no_resolve = 1;
- if (ngx_parse_url (r->pool, &u) != NGX_OK) {
+ if (ngx_parse_url(r->pool, &u) != NGX_OK) {
if (u.err) {
- ngx_log_error (NGX_LOG_ERR, r->connection->log, 0,
- "%s in upstream \"%V\"", u.err, &u.url);
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "%s in upstream \"%V\"", u.err, &u.url);
}
return NGX_ERROR;
}
if (u.no_port) {
- ngx_log_error (NGX_LOG_ERR, r->connection->log, 0,
- "no port in upstream \"%V\"", &u.url);
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "no port in upstream \"%V\"", &u.url);
return NGX_ERROR;
}
- r->upstream->resolved = ngx_pcalloc (r->pool,
- sizeof
- (ngx_http_upstream_resolved_t));
+ r->upstream->resolved = ngx_pcalloc(r->pool,
+ sizeof(ngx_http_upstream_resolved_t));
if (r->upstream->resolved == NULL) {
return NGX_ERROR;
}
@@ -473,8 +454,7 @@ ngx_http_uwsgi_eval (ngx_http_request_t * r, ngx_http_uwsgi_loc_conf_t * uwcf)
r->upstream->resolved->naddrs = 1;
r->upstream->resolved->host = u.addrs[0].name;
- }
- else {
+ } else {
r->upstream->resolved->host = u.host;
r->upstream->resolved->port = u.port;
}
@@ -484,29 +464,29 @@ ngx_http_uwsgi_eval (ngx_http_request_t * r, ngx_http_uwsgi_loc_conf_t * uwcf)
static ngx_int_t
-ngx_http_uwsgi_create_request (ngx_http_request_t * r)
+ngx_http_uwsgi_create_request(ngx_http_request_t *r)
{
- u_char ch, *pos, tmp[2];
- size_t key_len, val_len;
- uint16_t uwsgi_pkt_size, uwsgi_strlen;
- ngx_uint_t i, n;
- ngx_buf_t *b;
- ngx_chain_t *cl, *body;
- ngx_list_part_t *part;
- ngx_table_elt_t *header;
- ngx_http_script_code_pt code;
- ngx_http_script_engine_t e, le;
- ngx_http_uwsgi_loc_conf_t *uwcf;
- ngx_http_script_len_code_pt lcode;
+ u_char ch, *pos, tmp[2];
+ size_t key_len, val_len;
+ uint16_t uwsgi_pkt_size, uwsgi_strlen;
+ ngx_uint_t i, n;
+ ngx_buf_t *b;
+ ngx_chain_t *cl, *body;
+ ngx_list_part_t *part;
+ ngx_table_elt_t *header;
+ ngx_http_script_code_pt code;
+ ngx_http_script_engine_t e, le;
+ ngx_http_uwsgi_loc_conf_t *uwcf;
+ ngx_http_script_len_code_pt lcode;
uwsgi_pkt_size = 0;
- uwcf = ngx_http_get_module_loc_conf (r, ngx_http_uwsgi_module);
+ uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
if (uwcf->params_len) {
- ngx_memzero (&le, sizeof (ngx_http_script_engine_t));
+ ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
- ngx_http_script_flush_no_cacheable_variables (r, uwcf->flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, uwcf->flushes);
le.flushed = 1;
le.ip = uwcf->params_len->elts;
@@ -515,14 +495,15 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
while (*(uintptr_t *) le.ip) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
- key_len = lcode (&le);
+ key_len = lcode(&le);
for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
}
- le.ip += sizeof (uintptr_t);
+ le.ip += sizeof(uintptr_t);
- uwsgi_pkt_size += 2 + key_len + 2 + val_len;
+ uwsgi_pkt_size = (uint16_t)
+ (uwsgi_pkt_size + 2 + key_len + 2 + val_len);
}
}
@@ -543,30 +524,30 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
i = 0;
}
- uwsgi_pkt_size +=
- 2 + 5 + header[i].key.len + 2 + header[i].value.len;
+ uwsgi_pkt_size = (uint16_t) (uwsgi_pkt_size
+ + 2 + 5 + header[i].key.len + 2 + header[i].value.len);
}
}
if (uwcf->uwsgi_string.data && uwcf->uwsgi_string.len) {
- uwsgi_pkt_size += uwcf->uwsgi_string.len ;
+ uwsgi_pkt_size = (uint16_t) (uwsgi_pkt_size + uwcf->uwsgi_string.len);
}
-
- /* allow custom uwsgi packet
+#if 0
+ /* allow custom uwsgi packet */
if (uwsgi_pkt_size > 0 && uwsgi_pkt_size < 2) {
ngx_log_error (NGX_LOG_ALERT, r->connection->log, 0,
"uwsgi request is too little: %uz", uwsgi_pkt_size);
return NGX_ERROR;
}
- */
+#endif
- b = ngx_create_temp_buf (r->pool, uwsgi_pkt_size + 4);
+ b = ngx_create_temp_buf(r->pool, uwsgi_pkt_size + 4);
if (b == NULL) {
return NGX_ERROR;
}
- cl = ngx_alloc_chain_link (r->pool);
+ cl = ngx_alloc_chain_link(r->pool);
if (cl == NULL) {
return NGX_ERROR;
}
@@ -575,14 +556,14 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
*b->pos = uwcf->modifier1;
#ifndef NGX_HAVE_LITTLE_ENDIAN
- uwsgi_pkt_size = uwsgi_swap16 (uwsgi_pkt_size);
+ uwsgi_pkt_size = uwsgi_swap16(uwsgi_pkt_size);
#endif
- b->last = ngx_cpymem (b->pos + 1, &uwsgi_pkt_size, 2);
+ b->last = ngx_cpymem(b->pos + 1, &uwsgi_pkt_size, 2);
*(b->pos + 3) = uwcf->modifier2;
b->last++;
if (uwcf->params_len) {
- ngx_memzero (&e, sizeof (ngx_http_script_engine_t));
+ ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
e.ip = uwcf->params->elts;
e.pos = b->last;
@@ -596,50 +577,47 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
lcode = *(ngx_http_script_len_code_pt *) le.ip;
key_len = (u_char) lcode (&le);
- for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) {
+ for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
}
- le.ip += sizeof (uintptr_t);
+ le.ip += sizeof(uintptr_t);
#ifndef NGX_HAVE_LITTLE_ENDIAN
- uwsgi_strlen = uwsgi_swap16 (key_len);
+ uwsgi_strlen = uwsgi_swap16(key_len);
#else
- uwsgi_strlen = key_len;
+ uwsgi_strlen = (uint16_t) key_len;
#endif
- e.pos = ngx_cpymem (e.pos, &uwsgi_strlen, 2);
+ e.pos = ngx_cpymem(e.pos, &uwsgi_strlen, 2);
while (*(uintptr_t *) e.ip) {
code = *(ngx_http_script_code_pt *) e.ip;
- code ((ngx_http_script_engine_t *) & e);
+ code((ngx_http_script_engine_t *) & e);
}
pos = e.pos - val_len;
/* move memory */
for (i = 0; i < val_len; i += 2) {
- e.pos = ngx_cpymem (tmp, pos + (i) + 2, 2);
- e.pos = ngx_cpymem (pos + (i) + 2, pos, 2);
- e.pos = ngx_cpymem (pos, tmp, 2);
+ e.pos = ngx_cpymem(tmp, pos + i + 2, 2);
+ e.pos = ngx_cpymem(pos + i + 2, pos, 2);
+ e.pos = ngx_cpymem(pos, tmp, 2);
}
e.pos = pos;
#ifndef NGX_HAVE_LITTLE_ENDIAN
- uwsgi_strlen = uwsgi_swap16 (val_len);
+ uwsgi_strlen = uwsgi_swap16(val_len);
#else
- uwsgi_strlen = val_len;
+ uwsgi_strlen = (uint16_t) val_len;
#endif
- e.pos = ngx_cpymem (e.pos, &uwsgi_strlen, 2);
+ e.pos = ngx_cpymem(e.pos, &uwsgi_strlen, 2);
e.pos += val_len;
- e.ip += sizeof (uintptr_t);
-
-
+ e.ip += sizeof(uintptr_t);
}
b->last = e.pos;
}
-
if (uwcf->upstream.pass_request_headers) {
part = &r->headers_in.headers.part;
@@ -658,20 +636,19 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
}
#ifndef NGX_HAVE_LITTLE_ENDIAN
- uwsgi_strlen = uwsgi_swap16 (5 + header[i].key.len);
+ uwsgi_strlen = uwsgi_swap16(5 + header[i].key.len);
#else
- uwsgi_strlen = 5 + header[i].key.len;
+ uwsgi_strlen = (uint16_t) (5 + header[i].key.len);
#endif
- b->last = ngx_cpymem (b->last, &uwsgi_strlen, 2);
- b->last = ngx_cpymem (b->last, "HTTP_", 5);
+ b->last = ngx_cpymem(b->last, &uwsgi_strlen, 2);
+ b->last = ngx_cpymem(b->last, "HTTP_", 5);
for (n = 0; n < header[i].key.len; n++) {
ch = header[i].key.data[n];
if (ch >= 'a' && ch <= 'z') {
ch &= ~0x20;
- }
- else if (ch == '-') {
+ } else if (ch == '-') {
ch = '_';
}
@@ -680,20 +657,17 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
#ifndef NGX_HAVE_LITTLE_ENDIAN
uwsgi_strlen = uwsgi_swap16 (header[i].value.len);
#else
- uwsgi_strlen = header[i].value.len;
+ uwsgi_strlen = (uint16_t) header[i].value.len;
#endif
- b->last = ngx_cpymem (b->last, &uwsgi_strlen, 2);
+ b->last = ngx_cpymem(b->last, &uwsgi_strlen, 2);
b->last =
- ngx_copy (b->last, header[i].value.data, header[i].value.len);
-
-
+ ngx_copy(b->last, header[i].value.data, header[i].value.len);
}
}
-
-
if (uwcf->uwsgi_string.data && uwcf->uwsgi_string.len) {
- b->last = ngx_copy(b->last, uwcf->uwsgi_string.data, uwcf->uwsgi_string.len);
+ b->last = ngx_copy(b->last, uwcf->uwsgi_string.data,
+ uwcf->uwsgi_string.len);
}
if (uwcf->upstream.pass_request_body) {
@@ -701,14 +675,14 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
r->upstream->request_bufs = cl;
while (body) {
- b = ngx_alloc_buf (r->pool);
+ b = ngx_alloc_buf(r->pool);
if (b == NULL) {
return NGX_ERROR;
}
- ngx_memcpy (b, body->buf, sizeof (ngx_buf_t));
+ ngx_memcpy(b, body->buf, sizeof(ngx_buf_t));
- cl->next = ngx_alloc_chain_link (r->pool);
+ cl->next = ngx_alloc_chain_link(r->pool);
if (cl->next == NULL) {
return NGX_ERROR;
}
@@ -721,8 +695,7 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
b->flush = 1;
- }
- else {
+ } else {
r->upstream->request_bufs = cl;
}
@@ -733,21 +706,20 @@ ngx_http_uwsgi_create_request (ngx_http_request_t * r)
static ngx_int_t
-ngx_http_uwsgi_reinit_request (ngx_http_request_t * r)
+ngx_http_uwsgi_reinit_request(ngx_http_request_t *r)
{
+ ngx_http_uwsgi_ctx_t *ctx;
- ngx_http_uwsgi_ctx_t *s;
-
- s = ngx_http_get_module_ctx (r, ngx_http_uwsgi_module);
+ ctx = ngx_http_get_module_ctx(r, ngx_http_uwsgi_module);
- if (s == NULL) {
+ if (ctx == NULL) {
return NGX_OK;
}
- s->status = 0;
- s->status_count = 0;
- s->status_start = NULL;
- s->status_end = NULL;
+ ctx->status = 0;
+ ctx->status_count = 0;
+ ctx->status_start = NULL;
+ ctx->status_end = NULL;
r->upstream->process_header = ngx_http_uwsgi_process_status_line;
@@ -755,12 +727,12 @@ ngx_http_uwsgi_reinit_request (ngx_http_request_t * r)
}
static ngx_int_t
-ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
- ngx_http_uwsgi_ctx_t * ctx)
+ngx_http_uwsgi_parse_status_line(ngx_http_request_t *r,
+ ngx_http_uwsgi_ctx_t *ctx)
{
- u_char ch;
- u_char *p;
- ngx_http_upstream_t *u;
+ u_char ch;
+ u_char *p;
+ ngx_http_upstream_t *u;
enum {
sw_start = 0,
sw_H,
@@ -786,14 +758,14 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
switch (state) {
- /* "HTTP/" */
+ /* "HTTP/" */
case sw_start:
switch (ch) {
case 'H':
state = sw_H;
break;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@@ -803,7 +775,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_HT;
break;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@@ -813,7 +785,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_HTT;
break;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@@ -823,7 +795,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_HTTP;
break;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
@@ -833,20 +805,20 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
state = sw_first_major_digit;
break;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
- /* the first digit of major HTTP version */
+ /* the first digit of major HTTP version */
case sw_first_major_digit:
if (ch < '1' || ch > '9') {
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
state = sw_major_digit;
break;
- /* the major HTTP version or dot */
+ /* the major HTTP version or dot */
case sw_major_digit:
if (ch == '.') {
state = sw_first_minor_digit;
@@ -854,21 +826,21 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
}
if (ch < '0' || ch > '9') {
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
- /* the first digit of minor HTTP version */
+ /* the first digit of minor HTTP version */
case sw_first_minor_digit:
if (ch < '0' || ch > '9') {
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
state = sw_minor_digit;
break;
- /* the minor HTTP version or the end of the request line */
+ /* the minor HTTP version or the end of the request line */
case sw_minor_digit:
if (ch == ' ') {
state = sw_status;
@@ -876,19 +848,19 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
}
if (ch < '0' || ch > '9') {
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
- /* HTTP status code */
+ /* HTTP status code */
case sw_status:
if (ch == ' ') {
break;
}
if (ch < '0' || ch > '9') {
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
ctx->status = ctx->status * 10 + ch - '0';
@@ -900,7 +872,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
break;
- /* space or end of line */
+ /* space or end of line */
case sw_space_after_status:
switch (ch) {
case ' ':
@@ -915,11 +887,11 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
case LF:
goto done;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
break;
- /* any text until end of line */
+ /* any text until end of line */
case sw_status_text:
switch (ch) {
case CR:
@@ -931,14 +903,14 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
}
break;
- /* end of status line */
+ /* end of status line */
case sw_almost_done:
ctx->status_end = p - 1;
switch (ch) {
case LF:
goto done;
default:
- return NGX_HTTP_XCGI_PARSE_NO_HEADER;
+ return NGX_HTTP_UWSGI_PARSE_NO_HEADER;
}
}
}
@@ -948,7 +920,7 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
return NGX_AGAIN;
- done:
+done:
u->buffer.pos = p + 1;
@@ -963,19 +935,19 @@ ngx_http_uwsgi_parse_status_line (ngx_http_request_t * r,
static ngx_int_t
-ngx_http_uwsgi_process_status_line (ngx_http_request_t * r)
+ngx_http_uwsgi_process_status_line(ngx_http_request_t *r)
{
- ngx_int_t rc;
- ngx_http_upstream_t *u;
- ngx_http_uwsgi_ctx_t *ctx;
+ ngx_int_t rc;
+ ngx_http_upstream_t *u;
+ ngx_http_uwsgi_ctx_t *ctx;
- ctx = ngx_http_get_module_ctx (r, ngx_http_uwsgi_module);
+ ctx = ngx_http_get_module_ctx(r, ngx_http_uwsgi_module);
if (ctx == NULL) {
return NGX_ERROR;
}
- rc = ngx_http_uwsgi_parse_status_line (r, ctx);
+ rc = ngx_http_uwsgi_parse_status_line(r, ctx);
if (rc == NGX_AGAIN) {
return rc;
@@ -983,10 +955,10 @@ ngx_http_uwsgi_process_status_line (ngx_http_request_t * r)
u = r->upstream;
- if (rc == NGX_HTTP_XCGI_PARSE_NO_HEADER) {
+ if (rc == NGX_HTTP_UWSGI_PARSE_NO_HEADER) {
- ngx_log_error (NGX_LOG_ERR, r->connection->log, 0,
- "upstream sent no valid HTTP/1.0 header");
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "upstream sent no valid HTTP/1.0 header");
r->http_version = NGX_HTTP_VERSION_9;
u->headers_in.status_n = NGX_HTTP_OK;
@@ -1002,45 +974,44 @@ ngx_http_uwsgi_process_status_line (ngx_http_request_t * r)
u->headers_in.status_n = ctx->status;
u->headers_in.status_line.len = ctx->status_end - ctx->status_start;
- u->headers_in.status_line.data = ngx_pnalloc (r->pool,
- u->headers_in.
- status_line.len);
+ u->headers_in.status_line.data = ngx_pnalloc(r->pool,
+ u->headers_in.status_line.len);
if (u->headers_in.status_line.data == NULL) {
return NGX_ERROR;
}
- ngx_memcpy (u->headers_in.status_line.data, ctx->status_start,
- u->headers_in.status_line.len);
+ ngx_memcpy(u->headers_in.status_line.data, ctx->status_start,
+ u->headers_in.status_line.len);
- ngx_log_debug2 (NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http uwsgi status %ui \"%V\"",
- u->headers_in.status_n, &u->headers_in.status_line);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http uwsgi status %ui \"%V\"",
+ u->headers_in.status_n, &u->headers_in.status_line);
u->process_header = ngx_http_uwsgi_process_header;
- return ngx_http_uwsgi_process_header (r);
+ return ngx_http_uwsgi_process_header(r);
}
static ngx_int_t
-ngx_http_uwsgi_process_header (ngx_http_request_t * r)
+ngx_http_uwsgi_process_header(ngx_http_request_t *r)
{
- ngx_int_t rc;
- ngx_table_elt_t *h;
- ngx_http_upstream_header_t *hh;
- ngx_http_upstream_main_conf_t *umcf;
+ ngx_int_t rc;
+ ngx_table_elt_t *h;
+ ngx_http_upstream_header_t *hh;
+ ngx_http_upstream_main_conf_t *umcf;
- umcf = ngx_http_get_module_main_conf (r, ngx_http_upstream_module);
+ umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
- for (;;) {
+ for ( ;; ) {
- rc = ngx_http_parse_header_line (r, &r->upstream->buffer, 1);
+ rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1);
if (rc == NGX_OK) {
/* a header line has been parsed successfully */
- h = ngx_list_push (&r->upstream->headers_in.headers);
+ h = ngx_list_push(&r->upstream->headers_in.headers);
if (h == NULL) {
return NGX_ERROR;
}
@@ -1050,9 +1021,9 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
h->key.len = r->header_name_end - r->header_name_start;
h->value.len = r->header_end - r->header_start;
- h->key.data = ngx_pnalloc (r->pool,
- h->key.len + 1 + h->value.len + 1 +
- h->key.len);
+ h->key.data = ngx_pnalloc(r->pool,
+ h->key.len + 1 + h->value.len + 1
+ + h->key.len);
if (h->key.data == NULL) {
return NGX_ERROR;
}
@@ -1060,27 +1031,25 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
h->value.data = h->key.data + h->key.len + 1;
h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1;
- ngx_cpystrn (h->key.data, r->header_name_start, h->key.len + 1);
- ngx_cpystrn (h->value.data, r->header_start, h->value.len + 1);
+ ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1);
+ ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1);
if (h->key.len == r->lowcase_index) {
- ngx_memcpy (h->lowcase_key, r->lowcase_header, h->key.len);
+ ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
- }
- else {
- ngx_strlow (h->lowcase_key, h->key.data, h->key.len);
+ } else {
+ ngx_strlow(h->lowcase_key, h->key.data, h->key.len);
}
- hh = ngx_hash_find (&umcf->headers_in_hash, h->hash,
- h->lowcase_key, h->key.len);
+ hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
+ h->lowcase_key, h->key.len);
- if (hh && hh->handler (r, h, hh->offset) != NGX_OK) {
+ if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
return NGX_ERROR;
}
- ngx_log_debug2 (NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http uwsgi header: \"%V: %V\"",
- &h->key, &h->value);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http uwsgi header: \"%V: %V\"", &h->key, &h->value);
continue;
}
@@ -1089,8 +1058,8 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
/* a whole header has been parsed successfully */
- ngx_log_debug0 (NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http uwsgi header done");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http uwsgi header done");
/*
* if no "Server" and "Date" in header line,
@@ -1098,18 +1067,15 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
*/
if (r->upstream->headers_in.server == NULL) {
- h = ngx_list_push (&r->upstream->headers_in.headers);
+ h = ngx_list_push(&r->upstream->headers_in.headers);
if (h == NULL) {
return NGX_ERROR;
}
- h->hash =
- ngx_hash (ngx_hash
- (ngx_hash
- (ngx_hash (ngx_hash ('s', 'e'), 'r'),
- 'v'), 'e'), 'r');
+ h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash(
+ ngx_hash ('s', 'e'), 'r'), 'v'), 'e'), 'r');
- h->key.len = sizeof ("Server") - 1;
+ h->key.len = sizeof("Server") - 1;
h->key.data = (u_char *) "Server";
h->value.len = 0;
h->value.data = NULL;
@@ -1117,14 +1083,14 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
}
if (r->upstream->headers_in.date == NULL) {
- h = ngx_list_push (&r->upstream->headers_in.headers);
+ h = ngx_list_push(&r->upstream->headers_in.headers);
if (h == NULL) {
return NGX_ERROR;
}
- h->hash = ngx_hash (ngx_hash (ngx_hash ('d', 'a'), 't'), 'e');
+ h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e');
- h->key.len = sizeof ("Date") - 1;
+ h->key.len = sizeof("Date") - 1;
h->key.data = (u_char *) "Date";
h->value.len = 0;
h->value.data = NULL;
@@ -1140,8 +1106,8 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
/* there was error while a header line parsing */
- ngx_log_error (NGX_LOG_ERR, r->connection->log, 0,
- "upstream sent invalid header");
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "upstream sent invalid header");
return NGX_HTTP_UPSTREAM_INVALID_HEADER;
}
@@ -1149,32 +1115,32 @@ ngx_http_uwsgi_process_header (ngx_http_request_t * r)
static void
-ngx_http_uwsgi_abort_request (ngx_http_request_t * r)
+ngx_http_uwsgi_abort_request(ngx_http_request_t *r)
{
- ngx_log_debug0 (NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "abort http uwsgi request");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "abort http uwsgi request");
return;
}
static void
-ngx_http_uwsgi_finalize_request (ngx_http_request_t * r, ngx_int_t rc)
+ngx_http_uwsgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
{
- ngx_log_debug0 (NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "finalize http uwsgi request");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "finalize http uwsgi request");
return;
}
static ngx_int_t
-ngx_http_uwsgi_add_variables (ngx_conf_t * cf)
+ngx_http_uwsgi_add_variables(ngx_conf_t *cf)
{
- ngx_http_variable_t *var, *v;
+ ngx_http_variable_t *var, *v;
for (v = ngx_http_uwsgi_vars; v->name.len; v++) {
- var = ngx_http_add_variable (cf, &v->name, v->flags);
+ var = ngx_http_add_variable(cf, &v->name, v->flags);
if (var == NULL) {
return NGX_ERROR;
}
@@ -1188,11 +1154,11 @@ ngx_http_uwsgi_add_variables (ngx_conf_t * cf)
static void *
-ngx_http_uwsgi_create_loc_conf (ngx_conf_t * cf)
+ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
{
- ngx_http_uwsgi_loc_conf_t *conf;
+ ngx_http_uwsgi_loc_conf_t *conf;
- conf = ngx_pcalloc (cf->pool, sizeof (ngx_http_uwsgi_loc_conf_t));
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_uwsgi_loc_conf_t));
if (conf == NULL) {
return NULL;
}
@@ -1229,22 +1195,22 @@ ngx_http_uwsgi_create_loc_conf (ngx_conf_t * cf)
static char *
-ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
+ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
{
ngx_http_uwsgi_loc_conf_t *prev = parent;
ngx_http_uwsgi_loc_conf_t *conf = child;
- u_char *p;
- size_t size;
- uintptr_t *code;
- ngx_uint_t i;
- ngx_keyval_t *src;
- ngx_hash_init_t hash;
- ngx_http_script_compile_t sc;
- ngx_http_script_copy_code_t *copy;
+ u_char *p;
+ size_t size;
+ uintptr_t *code;
+ ngx_uint_t i;
+ ngx_keyval_t *src;
+ ngx_hash_init_t hash;
+ ngx_http_script_compile_t sc;
+ ngx_http_script_copy_code_t *copy;
if (conf->upstream.store != 0) {
- ngx_conf_merge_value (conf->upstream.store, prev->upstream.store, 0);
+ ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
if (conf->upstream.store_lengths == NULL) {
conf->upstream.store_lengths = prev->upstream.store_lengths;
@@ -1252,38 +1218,38 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
}
}
- ngx_conf_merge_uint_value (conf->upstream.store_access,
- prev->upstream.store_access, 0600);
+ ngx_conf_merge_uint_value(conf->upstream.store_access,
+ prev->upstream.store_access, 0600);
- ngx_conf_merge_value (conf->upstream.buffering,
- prev->upstream.buffering, 1);
+ ngx_conf_merge_value(conf->upstream.buffering,
+ prev->upstream.buffering, 1);
- ngx_conf_merge_value (conf->upstream.ignore_client_abort,
- prev->upstream.ignore_client_abort, 0);
+ ngx_conf_merge_value(conf->upstream.ignore_client_abort,
+ prev->upstream.ignore_client_abort, 0);
- ngx_conf_merge_msec_value (conf->upstream.connect_timeout,
- prev->upstream.connect_timeout, 60000);
+ ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
+ prev->upstream.connect_timeout, 60000);
- ngx_conf_merge_msec_value (conf->upstream.send_timeout,
- prev->upstream.send_timeout, 60000);
+ ngx_conf_merge_msec_value(conf->upstream.send_timeout,
+ prev->upstream.send_timeout, 60000);
- ngx_conf_merge_msec_value (conf->upstream.read_timeout,
- prev->upstream.read_timeout, 60000);
+ ngx_conf_merge_msec_value(conf->upstream.read_timeout,
+ prev->upstream.read_timeout, 60000);
- ngx_conf_merge_size_value (conf->upstream.send_lowat,
- prev->upstream.send_lowat, 0);
+ ngx_conf_merge_size_value(conf->upstream.send_lowat,
+ prev->upstream.send_lowat, 0);
- ngx_conf_merge_size_value (conf->upstream.buffer_size,
- prev->upstream.buffer_size,
- (size_t) ngx_pagesize);
+ ngx_conf_merge_size_value(conf->upstream.buffer_size,
+ prev->upstream.buffer_size,
+ (size_t) ngx_pagesize);
- ngx_conf_merge_bufs_value (conf->upstream.bufs, prev->upstream.bufs,
- 8, ngx_pagesize);
+ ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
+ 8, ngx_pagesize);
if (conf->upstream.bufs.num < 2) {
- ngx_conf_log_error (NGX_LOG_EMERG, cf, 0,
- "there must be at least 2 \"uwsgi_buffers\"");
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "there must be at least 2 \"uwsgi_buffers\"");
return NGX_CONF_ERROR;
}
@@ -1294,123 +1260,124 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
}
- ngx_conf_merge_size_value (conf->upstream.busy_buffers_size_conf,
- prev->upstream.busy_buffers_size_conf,
- NGX_CONF_UNSET_SIZE);
+ ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
+ prev->upstream.busy_buffers_size_conf,
+ NGX_CONF_UNSET_SIZE);
if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.busy_buffers_size = 2 * size;
- }
- else {
+ } else {
conf->upstream.busy_buffers_size =
conf->upstream.busy_buffers_size_conf;
}
if (conf->upstream.busy_buffers_size < size) {
- ngx_conf_log_error (NGX_LOG_EMERG, cf, 0,
- "\"uwsgi_busy_buffers_size\" must be equal or bigger than "
- "maximum of the value of \"uwsgi_buffer_size\" and "
- "one of the \"uwsgi_buffers\"");
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"uwsgi_busy_buffers_size\" must be equal or bigger "
+ "than maximum of the value of \"uwsgi_buffer_size\" and "
+ "one of the \"uwsgi_buffers\"");
return NGX_CONF_ERROR;
}
if (conf->upstream.busy_buffers_size
- > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) {
- ngx_conf_log_error (NGX_LOG_EMERG, cf, 0,
- "\"uwsgi_busy_buffers_size\" must be less than "
- "the size of all \"uwsgi_buffers\" minus one buffer");
+ > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
+ {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"uwsgi_busy_buffers_size\" must be less than "
+ "the size of all \"uwsgi_buffers\" minus one buffer");
return NGX_CONF_ERROR;
}
- ngx_conf_merge_size_value (conf->upstream.temp_file_write_size_conf,
- prev->upstream.temp_file_write_size_conf,
- NGX_CONF_UNSET_SIZE);
+ ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
+ prev->upstream.temp_file_write_size_conf,
+ NGX_CONF_UNSET_SIZE);
if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.temp_file_write_size = 2 * size;
- }
- else {
+ } else {
conf->upstream.temp_file_write_size =
conf->upstream.temp_file_write_size_conf;
}
if (conf->upstream.temp_file_write_size < size) {
- ngx_conf_log_error (NGX_LOG_EMERG, cf, 0,
- "\"uwsgi_temp_file_write_size\" must be equal or bigger than "
- "maximum of the value of \"uwsgi_buffer_size\" and "
- "one of the \"uwsgi_buffers\"");
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"uwsgi_temp_file_write_size\" must be equal or bigger than "
+ "maximum of the value of \"uwsgi_buffer_size\" and "
+ "one of the \"uwsgi_buffers\"");
return NGX_CONF_ERROR;
}
- ngx_conf_merge_size_value (conf->upstream.max_temp_file_size_conf,
- prev->upstream.max_temp_file_size_conf,
- NGX_CONF_UNSET_SIZE);
+ ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
+ prev->upstream.max_temp_file_size_conf,
+ NGX_CONF_UNSET_SIZE);
if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
- }
- else {
+ } else {
conf->upstream.max_temp_file_size =
conf->upstream.max_temp_file_size_conf;
}
if (conf->upstream.max_temp_file_size != 0
&& conf->upstream.max_temp_file_size < size) {
- ngx_conf_log_error (NGX_LOG_EMERG, cf, 0,
- "\"uwsgi_max_temp_file_size\" must be equal to zero to disable "
- "the temporary files usage or must be equal or bigger than "
- "maximum of the value of \"uwsgi_buffer_size\" and "
- "one of the \"uwsgi_buffers\"");
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"uwsgi_max_temp_file_size\" must be equal to zero to disable "
+ "the temporary files usage or must be equal or bigger than "
+ "maximum of the value of \"uwsgi_buffer_size\" and "
+ "one of the \"uwsgi_buffers\"");
return NGX_CONF_ERROR;
}
- ngx_conf_merge_bitmask_value (conf->upstream.ignore_headers,
- prev->upstream.ignore_headers,
- NGX_CONF_BITMASK_SET);
+ ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers,
+ prev->upstream.ignore_headers,
+ NGX_CONF_BITMASK_SET);
- ngx_conf_merge_bitmask_value (conf->upstream.next_upstream,
- prev->upstream.next_upstream,
- (NGX_CONF_BITMASK_SET
- | NGX_HTTP_UPSTREAM_FT_ERROR
- | NGX_HTTP_UPSTREAM_FT_TIMEOUT));
+ ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
+ prev->upstream.next_upstream,
+ (NGX_CONF_BITMASK_SET
+ |NGX_HTTP_UPSTREAM_FT_ERROR
+ |NGX_HTTP_UPSTREAM_FT_TIMEOUT));
if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
- | NGX_HTTP_UPSTREAM_FT_OFF;
+ |NGX_HTTP_UPSTREAM_FT_OFF;
}
- if (ngx_conf_merge_path_value (cf, &conf->upstream.temp_path,
- prev->upstream.temp_path,
- &ngx_http_uwsgi_temp_path) != NGX_OK) {
+ if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
+ prev->upstream.temp_path,
+ &ngx_http_uwsgi_temp_path)
+ != NGX_OK)
+ {
return NGX_CONF_ERROR;
}
- ngx_conf_merge_value (conf->upstream.pass_request_headers,
- prev->upstream.pass_request_headers, 1);
- ngx_conf_merge_value (conf->upstream.pass_request_body,
- prev->upstream.pass_request_body, 1);
+ ngx_conf_merge_value(conf->upstream.pass_request_headers,
+ prev->upstream.pass_request_headers, 1);
+ ngx_conf_merge_value(conf->upstream.pass_request_body,
+ prev->upstream.pass_request_body, 1);
- ngx_conf_merge_value (conf->upstream.intercept_errors,
- prev->upstream.intercept_errors, 0);
+ ngx_conf_merge_value(conf->upstream.intercept_errors,
+ prev->upstream.intercept_errors, 0);
ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");
hash.max_size = 512;
- hash.bucket_size = ngx_align (64, ngx_cacheline_size);
+ hash.bucket_size = ngx_align(64, ngx_cacheline_size);
hash.name = "uwsgi_hide_headers_hash";
- if (ngx_http_upstream_hide_headers_hash (cf, &conf->upstream,
- &prev->upstream,
- ngx_http_uwsgi_hide_headers,
- &hash) != NGX_OK) {
+ if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
+ &prev->upstream,
+ ngx_http_uwsgi_hide_headers, &hash)
+ != NGX_OK)
+ {
return NGX_CONF_ERROR;
}
@@ -1442,12 +1409,12 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
}
}
- conf->params_len = ngx_array_create (cf->pool, 64, 1);
+ conf->params_len = ngx_array_create(cf->pool, 64, 1);
if (conf->params_len == NULL) {
return NGX_CONF_ERROR;
}
- conf->params = ngx_array_create (cf->pool, 512, 1);
+ conf->params = ngx_array_create(cf->pool, 512, 1);
if (conf->params == NULL) {
return NGX_CONF_ERROR;
}
@@ -1455,34 +1422,33 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
src = conf->params_source->elts;
for (i = 0; i < conf->params_source->nelts; i++) {
- if (ngx_http_script_variables_count (&src[i].value) == 0) {
- copy = ngx_array_push_n (conf->params_len,
- sizeof (ngx_http_script_copy_code_t));
+ if (ngx_http_script_variables_count(&src[i].value) == 0) {
+ copy = ngx_array_push_n(conf->params_len,
+ sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_CONF_ERROR;
}
copy->code = (ngx_http_script_code_pt)
- ngx_http_script_copy_len_code;
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
-
- copy = ngx_array_push_n (conf->params_len,
- sizeof (ngx_http_script_copy_code_t));
+ copy = ngx_array_push_n(conf->params_len,
+ sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_CONF_ERROR;
}
copy->code = (ngx_http_script_code_pt)
- ngx_http_script_copy_len_code;
+ ngx_http_script_copy_len_code;
copy->len = src[i].value.len;
- size = (sizeof (ngx_http_script_copy_code_t)
+ size = (sizeof(ngx_http_script_copy_code_t)
+ src[i].key.len + src[i].value.len
- + sizeof (uintptr_t) - 1) & ~(sizeof (uintptr_t) - 1);
+ + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n (conf->params, size);
+ copy = ngx_array_push_n(conf->params, size);
if (copy == NULL) {
return NGX_CONF_ERROR;
}
@@ -1490,29 +1456,28 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
copy->code = ngx_http_script_copy_code;
copy->len = src[i].key.len + src[i].value.len;
- p = (u_char *) copy + sizeof (ngx_http_script_copy_code_t);
+ p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);
- p = ngx_cpymem (p, src[i].key.data, src[i].key.len);
- ngx_memcpy (p, src[i].value.data, src[i].value.len);
+ p = ngx_cpymem(p, src[i].key.data, src[i].key.len);
+ ngx_memcpy(p, src[i].value.data, src[i].value.len);
- }
- else {
- copy = ngx_array_push_n (conf->params_len,
- sizeof (ngx_http_script_copy_code_t));
+ } else {
+ copy = ngx_array_push_n(conf->params_len,
+ sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_CONF_ERROR;
}
copy->code = (ngx_http_script_code_pt)
- ngx_http_script_copy_len_code;
+ ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
- size = (sizeof (ngx_http_script_copy_code_t)
- + src[i].key.len + sizeof (uintptr_t) - 1)
- & ~(sizeof (uintptr_t) - 1);
+ size = (sizeof(ngx_http_script_copy_code_t)
+ + src[i].key.len + sizeof(uintptr_t) - 1)
+ & ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n (conf->params, size);
+ copy = ngx_array_push_n(conf->params, size);
if (copy == NULL) {
return NGX_CONF_ERROR;
}
@@ -1520,11 +1485,11 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
copy->code = ngx_http_script_copy_code;
copy->len = src[i].key.len;
- p = (u_char *) copy + sizeof (ngx_http_script_copy_code_t);
- ngx_memcpy (p, src[i].key.data, src[i].key.len);
+ p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);
+ ngx_memcpy(p, src[i].key.data, src[i].key.len);
- ngx_memzero (&sc, sizeof (ngx_http_script_compile_t));
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
sc.cf = cf;
sc.source = &src[i].value;
@@ -1532,12 +1497,12 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
sc.lengths = &conf->params_len;
sc.values = &conf->params;
- if (ngx_http_script_compile (&sc) != NGX_OK) {
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_CONF_ERROR;
}
}
- code = ngx_array_push_n (conf->params_len, sizeof (uintptr_t));
+ code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}
@@ -1545,7 +1510,7 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
*code = (uintptr_t) NULL;
- code = ngx_array_push_n (conf->params, sizeof (uintptr_t));
+ code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}
@@ -1553,7 +1518,7 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
*code = (uintptr_t) NULL;
}
- code = ngx_array_push_n (conf->params_len, sizeof (uintptr_t));
+ code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}
@@ -1565,15 +1530,15 @@ ngx_http_uwsgi_merge_loc_conf (ngx_conf_t * cf, void *parent, void *child)
static char *
-ngx_http_uwsgi_pass (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
+ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
- ngx_url_t u;
- ngx_str_t *value, *url;
- ngx_uint_t n;
- ngx_http_core_loc_conf_t *clcf;
- ngx_http_script_compile_t sc;
+ ngx_url_t u;
+ ngx_str_t *value, *url;
+ ngx_uint_t n;
+ ngx_http_core_loc_conf_t *clcf;
+ ngx_http_script_compile_t sc;
if (uwcf->upstream.upstream || uwcf->uwsgi_lengths) {
return "is duplicate";
@@ -1586,11 +1551,11 @@ ngx_http_uwsgi_pass (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
url = &value[1];
- n = ngx_http_script_variables_count (url);
+ n = ngx_http_script_variables_count(url);
if (n) {
- ngx_memzero (&sc, sizeof (ngx_http_script_compile_t));
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
sc.cf = cf;
sc.source = url;
@@ -1600,19 +1565,19 @@ ngx_http_uwsgi_pass (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
sc.complete_lengths = 1;
sc.complete_values = 1;
- if (ngx_http_script_compile (&sc) != NGX_OK) {
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_CONF_ERROR;
}
return NGX_CONF_OK;
}
- ngx_memzero (&u, sizeof (ngx_url_t));
+ ngx_memzero(&u, sizeof(ngx_url_t));
u.url = value[1];
u.no_resolve = 1;
- uwcf->upstream.upstream = ngx_http_upstream_add (cf, &u, 0);
+ uwcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
if (uwcf->upstream.upstream == NULL) {
return NGX_CONF_ERROR;
}
@@ -1624,30 +1589,31 @@ ngx_http_uwsgi_pass (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
return NGX_CONF_OK;
}
+
static char *
-ngx_http_uwsgi_modifier1 (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
+ngx_http_uwsgi_modifier1(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
- ngx_str_t *value;
+ ngx_str_t *value;
value = cf->args->elts;
- uwcf->modifier1 = (u_char) ngx_atoi (value[1].data, value[1].len);
+ uwcf->modifier1 = (u_char) ngx_atoi(value[1].data, value[1].len);
return NGX_CONF_OK;
}
+
static char *
-ngx_http_uwsgi_modifier2 (ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
+ngx_http_uwsgi_modifier2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
- ngx_str_t *value;
+ ngx_str_t *value;
value = cf->args->elts;
- uwcf->modifier2 = (u_char) ngx_atoi (value[1].data, value[1].len);
-
+ uwcf->modifier2 = (u_char) ngx_atoi(value[1].data, value[1].len);
return NGX_CONF_OK;
}