diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-10-24 06:53:41 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-24 06:53:41 +0000 |
commit | 12b4b00784bbc3cd934e2f2bbee79679684629e3 (patch) | |
tree | 602dfdcdc4fe5b21c17366eacfae63efcb03770e /src/http | |
parent | 8556e6da41e80772cb9710e4309d9ad44a7b360e (diff) | |
download | nginx-12b4b00784bbc3cd934e2f2bbee79679684629e3.tar.gz nginx-12b4b00784bbc3cd934e2f2bbee79679684629e3.zip |
nginx-0.0.1-2003-10-24-10:53:41 import
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 78 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 7 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 1 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 11 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.h | 2 | ||||
-rw-r--r-- | src/http/ngx_http_special_response.c | 11 |
6 files changed, 56 insertions, 54 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index a4e0afa1b..9e42b4416 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -50,12 +50,19 @@ static int ngx_http_gzip_filter_init(ngx_cycle_t *cycle); static void *ngx_http_gzip_create_conf(ngx_conf_t *cf); static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child); -static char *ngx_http_gzip_set_window(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf); -static char *ngx_http_gzip_set_hash(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf); +static char *ngx_http_gzip_set_window(ngx_conf_t *cf, void *post, void *data); +static char *ngx_http_gzip_set_hash(ngx_conf_t *cf, void *post, void *data); + + +static ngx_conf_num_bounds_t ngx_http_gzip_comp_level_bounds = { + ngx_conf_check_num_bounds, 1, 9 +}; + +static ngx_conf_post_handler_pt ngx_http_gzip_set_window_p = + ngx_http_gzip_set_window; +static ngx_conf_post_handler_pt ngx_http_gzip_set_hash_p = + ngx_http_gzip_set_hash; -static ngx_conf_bounds_t ngx_http_gzip_comp_level_bounds; static ngx_command_t ngx_http_gzip_filter_commands[] = { @@ -83,17 +90,17 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = { {ngx_string("gzip_window"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_http_gzip_set_window, + ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_gzip_conf_t, wbits), - NULL}, + &ngx_http_gzip_set_window_p}, {ngx_string("gzip_hash"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_http_gzip_set_hash, + ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_gzip_conf_t, memlevel), - NULL}, + &ngx_http_gzip_set_hash_p}, {ngx_string("gzip_no_buffer"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, @@ -128,12 +135,7 @@ ngx_module_t ngx_http_gzip_filter_module = { }; -static ngx_conf_bounds_t ngx_http_gzip_comp_level_bounds = { - ngx_conf_check_num_bounds, { { 1, 9 } } -}; - - -static u_char gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 }; +static u_char gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 }; #if (HAVE_LITTLE_ENDIAN) @@ -240,8 +242,8 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) /* * We preallocate a memory for zlib in one hunk (200K-400K), this - * dicreases number of malloc() and free() calls and probably - * syscalls. + * dicreases a number of malloc() and free() calls and also probably + * dicreases a number of syscalls. * Besides we free() this memory as soon as the gzipping will complete * and do not wait while a whole response will be sent to a client. * @@ -591,28 +593,21 @@ static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, } -static char *ngx_http_gzip_set_window(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf) +static char *ngx_http_gzip_set_window(ngx_conf_t *cf, void *post, void *data) { - ngx_http_gzip_conf_t *lcf = conf; - - int wbits, wsize; - char *rv; + int *np = data; + int wbits, wsize; - rv = ngx_conf_set_size_slot(cf, cmd, conf); - if (rv) { - return rv; - } -ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", lcf->wbits); +ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", *np); wbits = 15; for (wsize = 32 * 1024; wsize > 256; wsize >>= 1) { - if (wsize == lcf->wbits) { - lcf->wbits = wbits; -ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", lcf->wbits); + if (wsize == *np) { + *np = wbits; +ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", *np); return NULL; } @@ -623,28 +618,21 @@ ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", lcf->wbits); } -static char *ngx_http_gzip_set_hash(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf) +static char *ngx_http_gzip_set_hash(ngx_conf_t *cf, void *post, void *data) { - ngx_http_gzip_conf_t *lcf = conf; - - int memlevel, hsize; - char *rv; + int *np = data; + int memlevel, hsize; - rv = ngx_conf_set_size_slot(cf, cmd, conf); - if (rv) { - return rv; - } -ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "MEMLEVEL: %d", lcf->memlevel); +ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "MEMLEVEL: %d", *np); memlevel = 9; for (hsize = 128 * 1024; hsize > 256; hsize >>= 1) { - if (hsize == lcf->memlevel) { - lcf->memlevel = memlevel; -ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "MEMLEVEL: %d", lcf->memlevel); + if (hsize == *np) { + *np = memlevel; +ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "MEMLEVEL: %d", *np); return NULL; } diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 888c912f8..628eeeca3 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -188,8 +188,6 @@ static int ngx_http_proxy_handler(ngx_http_request_t *r) /* STUB */ p->accel = 1; - p->host_header = p->upstream.peers->peers[0].host; - ngx_test_null(p->request_hunks, ngx_http_proxy_create_request(p), NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -220,7 +218,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) + r->uri.len - p->location_len + 1 + r->args.len /* 1 is for "?" */ + sizeof(http_version) - 1 - + sizeof(host_header) - 1 + p->host_header.len + 2 + + sizeof(host_header) - 1 + p->lcf->upstream->host_header.len + 2 /* 2 is for "\r\n" */ + sizeof(connection_close_header) - 1 + 2; /* 2 is for "\r\n" at the header end */ @@ -268,7 +266,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) /* the "Host" header */ h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1); - h->last = ngx_cpymem(h->last, p->host_header.data, p->host_header.len); + h->last = ngx_cpymem(h->last, p->lcf->upstream->host_header.data, + p->lcf->upstream->host_header.len); *(h->last++) = CR; *(h->last++) = LF; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index dedb06ac2..ea33083a3 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -73,7 +73,6 @@ struct ngx_http_proxy_ctx_s { int method; ngx_str_t uri; int location_len; - ngx_str_t host_header; ngx_event_pipe_t *event_pipe; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 8c96d0e6f..ad557e49e 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -165,6 +165,13 @@ static ngx_command_t ngx_http_core_commands[] = { offsetof(ngx_http_core_loc_conf_t, lingering_timeout), NULL}, + {ngx_string("msie_padding"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_flag_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_core_loc_conf_t, msie_padding), + NULL}, + {ngx_string("error_log"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_set_error_log, @@ -843,6 +850,8 @@ static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf) lcf->lingering_time = NGX_CONF_UNSET; lcf->lingering_timeout = NGX_CONF_UNSET; + lcf->msie_padding = NGX_CONF_UNSET; + return lcf; } @@ -916,6 +925,8 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf, ngx_conf_merge_msec_value(conf->lingering_timeout, prev->lingering_timeout, 5000); + ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1); + return NGX_CONF_OK; } diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 9cc979145..7ffebb46d 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -118,6 +118,8 @@ typedef struct { ngx_msec_t lingering_time; /* lingering_time */ ngx_msec_t lingering_timeout; /* lingering_timeout */ + int msie_padding; /* msie_padding */ + ngx_log_t *err_log; } ngx_http_core_loc_conf_t; diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index 2b274d5a0..ce6183e8b 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -152,9 +152,10 @@ static ngx_str_t error_pages[] = { int ngx_http_special_response_handler(ngx_http_request_t *r, int error) { - int err, rc; - ngx_hunk_t *h; - ngx_chain_t *out, **ll, *cl; + int err, rc; + ngx_hunk_t *h; + ngx_chain_t *out, **ll, *cl; + ngx_http_core_loc_conf_t *clcf; r->headers_out.status = error; @@ -238,7 +239,9 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error) ngx_alloc_link_and_set_hunk(cl, h, r->pool, NGX_ERROR); ngx_chain_add_link(out, ll, cl); - if (/* STUB: "msie_padding on/off" */ 1 + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + if (clcf->msie_padding && r->http_version >= NGX_HTTP_VERSION_10 && error >= NGX_HTTP_BAD_REQUEST && error != NGX_HTTP_REQUEST_URI_TOO_LARGE |