diff options
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_chunked_filter.c | 4 | ||||
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 54 | ||||
-rw-r--r-- | src/http/modules/ngx_http_index_handler.c | 18 | ||||
-rw-r--r-- | src/http/modules/ngx_http_range_filter.c | 35 | ||||
-rw-r--r-- | src/http/modules/ngx_http_rewrite_handler.c | 13 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssi_filter.c | 22 | ||||
-rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 27 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 66 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 54 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_header.c | 4 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_parse.c | 4 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 2 |
12 files changed, 167 insertions, 136 deletions
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c index ed7b460c1..21e2f5b7c 100644 --- a/src/http/modules/ngx_http_chunked_filter.c +++ b/src/http/modules/ngx_http_chunked_filter.c @@ -56,7 +56,7 @@ static int ngx_http_chunked_header_filter(ngx_http_request_t *r) static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in) { - char *chunk; + u_char *chunk; size_t size, len; ngx_hunk_t *h; ngx_chain_t *out, *cl, *tl, **ll; @@ -87,7 +87,7 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR); - len = ngx_snprintf(chunk, 11, SIZE_T_X_FMT CRLF, size); + len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size); ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index 18ad074fc..57177b509 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -7,12 +7,14 @@ typedef struct { - int enable; + ngx_flag_t enable; + ngx_flag_t no_buffer; + ngx_bufs_t bufs; + int level; - ssize_t wbits; - ssize_t memlevel; - int no_buffer; + int wbits; + int memlevel; } ngx_http_gzip_conf_t; @@ -39,7 +41,7 @@ typedef struct { size_t zin; size_t zout; - u_int crc32; + uint32_t crc32; z_stream zstream; ngx_http_request_t *request; } ngx_http_gzip_ctx_t; @@ -51,8 +53,8 @@ static void ngx_http_gzip_filter_free(void *opaque, void *address); ngx_inline static int ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx); -static char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, char *buf, - uintptr_t data); +static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, + uintptr_t data); static int ngx_http_gzip_pre_conf(ngx_conf_t *cf); static int ngx_http_gzip_filter_init(ngx_cycle_t *cycle); @@ -158,15 +160,15 @@ static u_char gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 }; #if (HAVE_LITTLE_ENDIAN) struct gztrailer { - u_int crc32; - u_int zlen; + uint32_t crc32; + uint32_t zlen; }; #else /* HAVE_BIG_ENDIAN */ struct gztrailer { - u_char crc32[4]; - u_char zlen[4]; + u_char crc32[4]; + u_char zlen[4]; }; #endif @@ -296,7 +298,7 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ngx_test_null(h, ngx_calloc_hunk(r->pool), ngx_http_gzip_error(ctx)); h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY; - h->pos = (char *) gzheader; + h->pos = gzheader; h->last = h->pos + 10; ngx_alloc_link_and_set_hunk(cl, h, r->pool, ngx_http_gzip_error(ctx)); @@ -396,8 +398,8 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ctx->zstream.avail_in, ctx->zstream.avail_out, rc); - ctx->in_hunk->pos = (char *) ctx->zstream.next_in; - ctx->out_hunk->last = (char *) ctx->zstream.next_out; + ctx->in_hunk->pos = ctx->zstream.next_in; + ctx->out_hunk->last = ctx->zstream.next_out; if (ctx->zstream.avail_out == 0) { ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool, @@ -558,10 +560,10 @@ static void ngx_http_gzip_filter_free(void *opaque, void *address) } -static char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, char *buf, - uintptr_t data) +static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, + uintptr_t data) { - u_int zint, zfrac; + ngx_uint_t zint, zfrac; ngx_http_gzip_ctx_t *ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); @@ -572,14 +574,14 @@ static char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, char *buf, } #if 0 - return buf + ngx_snprintf(buf, NGX_INT32_LEN + 4, "%.2f", + return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4, "%.2f", (float) ctx->zin / ctx->zout); #endif /* we prefer do not use FPU */ - zint = ctx->zin / ctx->zout; - zfrac = (ctx->zin * 100 / ctx->zout) % 100; + zint = (ngx_uint_t) (ctx->zin / ctx->zout); + zfrac = (ngx_uint_t) ((ctx->zin * 100 / ctx->zout) % 100); if ((ctx->zin * 1000 / ctx->zout) %10 > 4) { if (++zfrac > 99) { @@ -588,7 +590,8 @@ static char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, char *buf, } } - return buf + ngx_snprintf(buf, NGX_INT32_LEN + 4, "%d.%02d", zint, zfrac); + return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4, + "%d.%02d", zint, zfrac); } @@ -647,8 +650,10 @@ static void *ngx_http_gzip_create_conf(ngx_conf_t *cf) NGX_CONF_ERROR); conf->enable = NGX_CONF_UNSET; - /* conf->bufs.num = 0; */ conf->no_buffer = NGX_CONF_UNSET; + + /* conf->bufs.num = 0; */ + conf->level = NGX_CONF_UNSET; conf->wbits = NGX_CONF_UNSET; conf->memlevel = NGX_CONF_UNSET; @@ -667,9 +672,8 @@ static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, /* STUB: PAGE_SIZE */ 4096); ngx_conf_merge_value(conf->level, prev->level, 1); - ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS); - ngx_conf_merge_size_value(conf->memlevel, prev->memlevel, - MAX_MEM_LEVEL - 1); + ngx_conf_merge_value(conf->wbits, prev->wbits, MAX_WBITS); + ngx_conf_merge_value(conf->memlevel, prev->memlevel, MAX_MEM_LEVEL - 1); ngx_conf_merge_value(conf->no_buffer, prev->no_buffer, 0); return NGX_CONF_OK; diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c index bec9d653f..dd965d0cc 100644 --- a/src/http/modules/ngx_http_index_handler.c +++ b/src/http/modules/ngx_http_index_handler.c @@ -12,8 +12,8 @@ typedef struct { typedef struct { - ngx_int_t index; - char *last; + ngx_uint_t index; + u_char *last; ngx_str_t path; ngx_str_t redirect; ngx_http_cache_t *cache; @@ -97,7 +97,7 @@ ngx_module_t ngx_http_index_module = { int ngx_http_index_handler(ngx_http_request_t *r) { - char *name; + u_char *name; size_t len; ngx_fd_t fd; ngx_int_t rc; @@ -161,13 +161,13 @@ int ngx_http_index_handler(ngx_http_request_t *r) #endif - len = clcf->doc_root.len + r->uri.len + ilcf->max_index_len; + len = clcf->root.len + r->uri.len + ilcf->max_index_len; if (!(ctx->path.data = ngx_palloc(r->pool, len))) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } - ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->doc_root.data, - clcf->doc_root.len); + ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data, + clcf->root.len); ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data, r->uri.len + 1); ctx->path.len = ctx->last - ctx->path.data; @@ -237,7 +237,7 @@ int ngx_http_index_handler(ngx_http_request_t *r) } else { ctx->redirect.len = r->uri.len + index[ctx->index].len; - r->file.name.len = clcf->doc_root.len + r->uri.len + r->file.name.len = clcf->root.len + r->uri.len + index[ctx->index].len; } @@ -387,7 +387,7 @@ static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf, ngx_http_index_loc_conf_t *prev = parent; ngx_http_index_loc_conf_t *conf = child; - int i; + ngx_uint_t i; ngx_str_t *index, *prev_index; if (conf->max_index_len == 0) { @@ -434,7 +434,7 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, { ngx_http_index_loc_conf_t *ilcf = conf; - int i; + ngx_uint_t i; ngx_str_t *index, *value; value = cf->args->elts; diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c index 676a9780f..3f3a6a3f1 100644 --- a/src/http/modules/ngx_http_range_filter.c +++ b/src/http/modules/ngx_http_range_filter.c @@ -44,7 +44,7 @@ typedef struct { } ngx_http_range_filter_ctx_t; -static int ngx_http_range_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_range_filter_init(ngx_cycle_t *cycle); static ngx_http_module_t ngx_http_range_filter_module_ctx = { @@ -75,10 +75,12 @@ static ngx_http_output_header_filter_pt ngx_http_next_header_filter; static ngx_http_output_body_filter_pt ngx_http_next_body_filter; -static int ngx_http_range_header_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r) { - ngx_int_t rc, boundary, suffix, len, i; - char *p; + ngx_int_t rc; + ngx_uint_t boundary, suffix, i; + u_char *p; + size_t len; off_t start, end; ngx_http_range_t *range; ngx_http_range_filter_ctx_t *ctx; @@ -235,9 +237,9 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) NGX_ERROR); r->headers_out.content_range->value.len = - ngx_snprintf(r->headers_out.content_range->value.data, - 8 + 20 + 1, "bytes */" OFF_T_FMT, - r->headers_out.content_length_n); + ngx_snprintf((char *) r->headers_out.content_range->value.data, + 8 + 20 + 1, "bytes */" OFF_T_FMT, + r->headers_out.content_length_n); r->headers_out.content_length_n = -1; if (r->headers_out.content_length) { @@ -268,7 +270,8 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) /* "Content-Range: bytes SSSS-EEEE/TTTT" header */ r->headers_out.content_range->value.len = - ngx_snprintf(r->headers_out.content_range->value.data, + ngx_snprintf((char *) + r->headers_out.content_range->value.data, 6 + 20 + 1 + 20 + 1 + 20 + 1, "bytes " OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT, range->start, range->end - 1, @@ -313,7 +316,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) if (r->headers_out.charset.len) { ctx->boundary_header.len = - ngx_snprintf(ctx->boundary_header.data, len, + ngx_snprintf((char *) ctx->boundary_header.data, len, CRLF "--%010u" CRLF "Content-Type: %s; charset=%s" CRLF "Content-Range: bytes ", @@ -325,7 +328,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) } else { ctx->boundary_header.len = - ngx_snprintf(ctx->boundary_header.data, len, + ngx_snprintf((char *) ctx->boundary_header.data, len, CRLF "--%010u" CRLF "Content-Type: %s" CRLF "Content-Range: bytes ", @@ -340,7 +343,8 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) /* "Content-Type: multipart/byteranges; boundary=0123456789" */ r->headers_out.content_type->value.len = - ngx_snprintf(r->headers_out.content_type->value.data, + ngx_snprintf((char *) + r->headers_out.content_type->value.data, 31 + 10 + 1, "multipart/byteranges; boundary=%010u", boundary); @@ -357,7 +361,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */ range[i].content_range.len = - ngx_snprintf(range[i].content_range.data, + ngx_snprintf((char *) range[i].content_range.data, 20 + 1 + 20 + 1 + 20 + 5, OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT CRLF CRLF, range[i].start, range[i].end - 1, @@ -376,9 +380,10 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) } -static int ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in) +static ngx_int_t ngx_http_range_body_filter(ngx_http_request_t *r, + ngx_chain_t *in) { - int i; + ngx_uint_t i; ngx_hunk_t *h; ngx_chain_t *out, *hcl, *rcl, *dcl, **ll; ngx_http_range_t *range; @@ -475,7 +480,7 @@ static int ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } -static int ngx_http_range_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_range_filter_init(ngx_cycle_t *cycle) { ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_range_header_filter; diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c index e06b54bf3..88c6a335f 100644 --- a/src/http/modules/ngx_http_rewrite_handler.c +++ b/src/http/modules/ngx_http_rewrite_handler.c @@ -82,10 +82,11 @@ ngx_module_t ngx_http_rewrite_module = { static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r) { int *matches; - char *p; + u_char *p; size_t len; uintptr_t data; - ngx_int_t rc, i, n, m; + ngx_int_t rc; + ngx_uint_t i, m, n; ngx_str_t uri; ngx_http_rewrite_op_t *op; ngx_http_rewrite_rule_t *rule; @@ -134,7 +135,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r) uri.len = rule[i].size; - for (n = 1; n < rc; n++) { + for (n = 1; n < (ngx_uint_t) rc; n++) { uri.len += matches[2 * n + 1] - matches[2 * n]; } @@ -150,7 +151,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r) len = op[n].len; data = op[n].data; while (len--) { - *p++ = data & 0xff; + *p++ = (char) (data & 0xff); data >>= 8; } @@ -208,13 +209,13 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd, { ngx_http_rewrite_srv_conf_t *scf = conf; - char *data, *p; + u_char *data, *p; size_t len; ngx_str_t *value, err; ngx_uint_t i; ngx_http_rewrite_op_t *op; ngx_http_rewrite_rule_t *rule; - char errstr[NGX_MAX_CONF_ERRSTR]; + u_char errstr[NGX_MAX_CONF_ERRSTR]; if (!(rule = ngx_push_array(&scf->rules))) { return NGX_CONF_ERROR; diff --git a/src/http/modules/ngx_http_ssi_filter.c b/src/http/modules/ngx_http_ssi_filter.c index 65ce128b9..f4ddb318e 100644 --- a/src/http/modules/ngx_http_ssi_filter.c +++ b/src/http/modules/ngx_http_ssi_filter.c @@ -15,8 +15,8 @@ typedef struct { - int enable; - ssize_t value_len; + ngx_flag_t enable; + size_t value_len; } ngx_http_ssi_conf_t; @@ -28,9 +28,9 @@ typedef struct { typedef struct { ngx_hunk_t *buf; - char *start; - char *last; - char *pos; + u_char *start; + u_char *last; + u_char *pos; ngx_str_t command; ngx_array_t params; @@ -41,7 +41,7 @@ typedef struct { ngx_chain_t **last_out; ngx_chain_t *busy; - int state; + ngx_uint_t state; size_t saved; } ngx_http_ssi_ctx_t; @@ -839,7 +839,7 @@ static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, break; default: - if ((ssize_t) ctx->param->value.len >= conf->value_len) { + if (ctx->param->value.len >= conf->value_len) { ctx->last = last; ctx->pos = p; ctx->state = ssi_error_state; @@ -853,7 +853,7 @@ static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, break; case ssi_double_quoted_value_quote_state: - if ((ssize_t) ctx->param->value.len >= conf->value_len) { + if (ctx->param->value.len >= conf->value_len) { ctx->last = last; ctx->pos = p; ctx->state = ssi_error_state; @@ -877,7 +877,7 @@ static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, break; default: - if ((ssize_t) ctx->param->value.len >= conf->value_len) { + if (ctx->param->value.len >= conf->value_len) { ctx->last = last; ctx->pos = p; ctx->state = ssi_error_state; @@ -891,7 +891,7 @@ static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, break; case ssi_quoted_value_quote_state: - if ((ssize_t) ctx->param->value.len >= conf->value_len) { + if (ctx->param->value.len >= conf->value_len) { ctx->last = last; ctx->pos = p; ctx->state = ssi_error_state; @@ -1006,7 +1006,7 @@ static void *ngx_http_ssi_create_conf(ngx_conf_t *cf) } conf->enable = NGX_CONF_UNSET; - conf->value_len = NGX_CONF_UNSET; + conf->value_len = NGX_CONF_UNSET_SIZE; return conf; } diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index 7876d2a24..0576255eb 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -60,7 +60,7 @@ ngx_module_t ngx_http_static_module = { static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) { - char *last; + u_char *last; ngx_fd_t fd; ngx_int_t rc; ngx_uint_t level; @@ -115,14 +115,31 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) * in a possible redirect and for the last '\0' */ - name.data = ngx_palloc(r->pool, clcf->doc_root.len + r->uri.len + 2); + name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2 + - clcf->alias * clcf->name.len); if (name.data == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } - location.data = ngx_cpymem(name.data, clcf->doc_root.data, - clcf->doc_root.len); - last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1); + location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len); + + if (clcf->alias) { + last = ngx_cpystrn(location.data, r->uri.data + clcf->name.len, + r->uri.len + 1 - clcf->name.len); + + /* + * aliases usually have trailling "/", + * set it in the start of the possible redirect + */ + + if (*location.data != '/') { + location.data--; + } + + } else { + last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1); + } + name.len = last - name.data; location.len = last - location.data + 1; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index e382f05e2..d36867dba 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -7,12 +7,12 @@ static int ngx_http_proxy_handler(ngx_http_request_t *r); -static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, - uintptr_t data); -static char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, char *buf, - uintptr_t data); -static char *ngx_http_proxy_log_reason(ngx_http_request_t *r, char *buf, - uintptr_t data); +static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, + u_char *buf, uintptr_t data); +static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, + u_char *buf, uintptr_t data); +static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf, + uintptr_t data); static int ngx_http_proxy_pre_conf(ngx_conf_t *cf); static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf); @@ -146,7 +146,7 @@ static ngx_command_t ngx_http_proxy_commands[] = { ngx_conf_set_path_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_proxy_loc_conf_t, temp_path), - ngx_garbage_collector_temp_handler }, + (void *) ngx_garbage_collector_temp_handler }, { ngx_string("proxy_temp_file_write_size"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, @@ -591,7 +591,7 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) ngx_close_socket_n " failed"); } - c->fd = -1; + c->fd = (ngx_socket_t) -1; } @@ -614,12 +614,12 @@ size_t ngx_http_proxy_log_error(void *data, char *buf, size_t len) ctx->proxy->lcf->upstream->uri.data, r->uri.data + ctx->proxy->lcf->upstream->location->len, r->args.len ? "?" : "", - r->args.len ? r->args.data : ""); + r->args.len ? r->args.data : (u_char *) ""); } -static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, - uintptr_t data) +static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, + u_char *buf, uintptr_t data) { ngx_http_proxy_ctx_t *p; @@ -644,7 +644,8 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, *buf++ = '-'; } else { - buf += ngx_snprintf(buf, NGX_TIME_T_LEN, TIME_T_FMT, p->state->expired); + buf += ngx_snprintf((char *) buf, NGX_TIME_T_LEN, + TIME_T_FMT, p->state->expired); } *buf++ = '/'; @@ -653,7 +654,8 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, *buf++ = '-'; } else { - buf += ngx_snprintf(buf, NGX_TIME_T_LEN, TIME_T_FMT, p->state->bl_time); + buf += ngx_snprintf((char *) buf, NGX_TIME_T_LEN, + TIME_T_FMT, p->state->bl_time); } *buf++ = '/'; @@ -666,7 +668,7 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, *buf++ = '-'; } else { - buf += ngx_snprintf(buf, 4, "%d", p->state->status); + buf += ngx_snprintf((char *) buf, 4, "%d", p->state->status); } *buf++ = '/'; @@ -685,7 +687,8 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, *buf++ = '-'; } else { - buf += ngx_snprintf(buf, NGX_TIME_T_LEN, TIME_T_FMT, p->state->expires); + buf += ngx_snprintf((char *) buf, NGX_TIME_T_LEN, + TIME_T_FMT, p->state->expires); } *buf++ = ' '; @@ -695,8 +698,8 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, } -static char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, char *buf, - uintptr_t data) +static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, + u_char *buf, uintptr_t data) { ngx_http_proxy_ctx_t *p; @@ -712,8 +715,8 @@ static char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, char *buf, } -static char *ngx_http_proxy_log_reason(ngx_http_request_t *r, char *buf, - uintptr_t data) +static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf, + uintptr_t data) { ngx_http_proxy_ctx_t *p; @@ -777,17 +780,17 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) */ - conf->request_buffer_size = NGX_CONF_UNSET; - conf->connect_timeout = NGX_CONF_UNSET; - conf->send_timeout = NGX_CONF_UNSET; + conf->request_buffer_size = NGX_CONF_UNSET_SIZE; + conf->connect_timeout = NGX_CONF_UNSET_MSEC; + conf->send_timeout = NGX_CONF_UNSET_MSEC; conf->preserve_host = NGX_CONF_UNSET; conf->set_x_real_ip = NGX_CONF_UNSET; conf->add_x_forwarded_for = NGX_CONF_UNSET; - conf->header_buffer_size = NGX_CONF_UNSET; - conf->read_timeout = NGX_CONF_UNSET; - conf->busy_buffers_size = NGX_CONF_UNSET; + conf->header_buffer_size = NGX_CONF_UNSET_SIZE; + conf->read_timeout = NGX_CONF_UNSET_MSEC; + conf->busy_buffers_size = NGX_CONF_UNSET_SIZE; /* * "proxy_max_temp_file_size" is hardcoded to 1G for reverse proxy, @@ -795,7 +798,7 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) */ conf->max_temp_file_size = 1024 * 1024 * 1024; - conf->temp_file_write_size = NGX_CONF_UNSET; + conf->temp_file_write_size = NGX_CONF_UNSET_SIZE; /* "proxy_cyclic_temp_file" is disabled */ conf->cyclic_temp_file = 0; @@ -906,8 +909,9 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd, { ngx_http_proxy_loc_conf_t *lcf = conf; - int i, len; - char *err, *host; + ngx_uint_t i, len; + char *err; + u_char *host; in_addr_t addr; ngx_str_t *value; struct hostent *h; @@ -946,10 +950,10 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd, /* AF_INET only */ - addr = inet_addr(host); + addr = inet_addr((char *) host); if (addr == INADDR_NONE) { - h = gethostbyname(host); + h = gethostbyname((char *) host); if (h == NULL || h->h_addr_list[0] == NULL) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "host %s not found", host); @@ -980,7 +984,7 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd, NGX_CONF_ERROR); len = ngx_inet_ntop(AF_INET, - (char *) &lcf->peers->peers[i].addr, + (u_char *) &lcf->peers->peers[i].addr, lcf->peers->peers[i].addr_port_text.data, len); diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index dd9cd15fc..2e6cb8473 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -40,40 +40,40 @@ typedef struct { ngx_str_t host_header; ngx_str_t port_text; ngx_str_t *location; - int port; + + ngx_int_t port; + unsigned default_port:1; } ngx_http_proxy_upstream_conf_t; typedef struct { - ssize_t request_buffer_size; + size_t request_buffer_size; + size_t header_buffer_size; + size_t busy_buffers_size; + size_t max_temp_file_size; + size_t temp_file_write_size; + ngx_msec_t connect_timeout; ngx_msec_t send_timeout; - ssize_t header_buffer_size; ngx_msec_t read_timeout; + time_t default_expires; + + ngx_int_t lm_factor; + + ngx_uint_t next_upstream; + ngx_uint_t use_stale; ngx_bufs_t bufs; - ssize_t busy_buffers_size; - ssize_t max_temp_file_size; - ssize_t temp_file_write_size; ngx_flag_t cyclic_temp_file; - ngx_flag_t cache; - ngx_flag_t preserve_host; ngx_flag_t set_x_real_ip; ngx_flag_t add_x_forwarded_for; - ngx_flag_t pass_server; ngx_flag_t pass_x_accel_expires; - ngx_flag_t ignore_expires; - int lm_factor; - time_t default_expires; - - u_int next_upstream; - u_int use_stale; ngx_path_t *cache_path; ngx_path_t *temp_path; @@ -96,9 +96,9 @@ typedef struct { ngx_http_proxy_state_e cache_state; time_t expired; time_t bl_time; - int bl_state; + ngx_uint_t bl_state; - int status; + ngx_uint_t status; ngx_http_proxy_reason_e reason; time_t time; time_t expires; @@ -130,7 +130,7 @@ typedef struct { typedef struct { ngx_http_cache_ctx_t ctx; - int status; + ngx_uint_t status; ngx_str_t status_line; ngx_http_proxy_headers_in_t headers_in; @@ -139,9 +139,9 @@ typedef struct { typedef struct { ngx_peer_connection_t peer; - int status; + ngx_uint_t status; ngx_str_t status_line; - int method; + ngx_uint_t method; ngx_output_chain_ctx_t *output_chain_ctx; ngx_event_pipe_t *event_pipe; @@ -175,23 +175,23 @@ struct ngx_http_proxy_ctx_s { /* used to parse an upstream HTTP header */ - int status; - char *status_start; - char *status_end; - int status_count; - int parse_state; + ngx_uint_t status; + u_char *status_start; + u_char *status_end; + ngx_uint_t status_count; + ngx_uint_t parse_state; ngx_http_proxy_state_t *state; ngx_array_t states; /* of ngx_http_proxy_state_t */ - char *action; + u_char *action; ngx_http_log_ctx_t *saved_ctx; ngx_log_handler_pt saved_handler; }; typedef struct { - u_int connection; + ngx_uint_t connection; ngx_http_proxy_ctx_t *proxy; } ngx_http_proxy_log_ctx_t; diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c index 0c44a5248..66a6bfe01 100644 --- a/src/http/modules/proxy/ngx_http_proxy_header.c +++ b/src/http/modules/proxy/ngx_http_proxy_header.c @@ -11,7 +11,7 @@ static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p, int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p, ngx_http_proxy_headers_in_t *headers_in) { - int i; + ngx_uint_t i; ngx_table_elt_t *ho, *h; ngx_http_request_t *r; @@ -97,7 +97,7 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p, static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p, ngx_table_elt_t *loc) { - char *last; + u_char *last; ngx_http_request_t *r; ngx_http_proxy_upstream_conf_t *uc; diff --git a/src/http/modules/proxy/ngx_http_proxy_parse.c b/src/http/modules/proxy/ngx_http_proxy_parse.c index a69795850..5e76dc043 100644 --- a/src/http/modules/proxy/ngx_http_proxy_parse.c +++ b/src/http/modules/proxy/ngx_http_proxy_parse.c @@ -7,8 +7,8 @@ int ngx_http_proxy_parse_status_line(ngx_http_proxy_ctx_t *p) { - char ch; - char *pos; + u_char ch; + u_char *pos; enum { sw_start = 0, sw_H, diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index dc55050bf..7704cb1ce 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -98,8 +98,8 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p) static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) { - int i; size_t len; + ngx_uint_t i; ngx_hunk_t *h; ngx_chain_t *chain; ngx_table_elt_t *header; |