diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2003-10-08 15:32:54 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-08 15:32:54 +0000 |
| commit | 3ae32483cd9315aef5066e2a06411e9ffb8a5560 (patch) | |
| tree | 423fdadc2fceefe023b8882287359ae7a28eceda /src/http/modules | |
| parent | fd3e374a02c7fc98d8193222885b453084f87727 (diff) | |
| download | nginx-3ae32483cd9315aef5066e2a06411e9ffb8a5560.tar.gz nginx-3ae32483cd9315aef5066e2a06411e9ffb8a5560.tar.bz2 | |
nginx-0.0.1-2003-10-08-19:32:54 import
Diffstat (limited to 'src/http/modules')
| -rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 53 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 4 |
2 files changed, 26 insertions, 31 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index cef987bc3..3e80c0b13 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -7,10 +7,9 @@ typedef struct { - int enable; - int hunk_size; - int hunks; - int no_buffer; + int enable; + ngx_bufs_t bufs; + int no_buffer; } ngx_http_gzip_conf_t; @@ -51,18 +50,11 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = { offsetof(ngx_http_gzip_conf_t, enable), NULL}, - {ngx_string("gzip_hunk_size"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, + {ngx_string("gzip_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_gzip_conf_t, hunk_size), - NULL}, - - {ngx_string("gzip_hunks"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_num_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_gzip_conf_t, hunks), + offsetof(ngx_http_gzip_conf_t, bufs), NULL}, {ngx_string("gzip_no_buffer"), @@ -173,7 +165,7 @@ static int ngx_http_gzip_header_filter(ngx_http_request_t *r) static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) { - int rc, wbits, mem_level, zin, zout; + int rc, wbits, mem_level, zin, zout, last; struct gztrailer *trailer; ngx_hunk_t *h; ngx_chain_t *ce; @@ -240,6 +232,8 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } } + last = NGX_NONE; + for ( ;; ) { for ( ;; ) { @@ -285,11 +279,12 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ctx->out_hunk = ctx->free->hunk; ctx->free = ctx->free->next; - } else if (ctx->hunks < conf->hunks) { + } else if (ctx->hunks < conf->bufs.num) { ngx_test_null(ctx->out_hunk, - ngx_create_temp_hunk(r->pool, conf->hunk_size, + ngx_create_temp_hunk(r->pool, conf->bufs.size, 0, 0), ngx_http_gzip_error(ctx)); + ctx->out_hunk->type |= NGX_HUNK_RECYCLED; ctx->hunks++; } else { @@ -297,7 +292,7 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } ctx->zstream.next_out = (unsigned char *) ctx->out_hunk->pos; - ctx->zstream.avail_out = conf->hunk_size; + ctx->zstream.avail_out = conf->bufs.size; } ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _ @@ -318,7 +313,7 @@ ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _ ctx->in_hunk->pos = (char *) ctx->zstream.next_in; if (ctx->zstream.avail_out == 0) { - ctx->out_hunk->last += conf->hunk_size; + ctx->out_hunk->last += conf->bufs.size; ngx_add_hunk_to_chain(ce, ctx->out_hunk, r->pool, ngx_http_gzip_error(ctx)); *ctx->last_out = ce; @@ -409,15 +404,13 @@ ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _ } } - if (ctx->out == NULL) { - if (ctx->in || ctx->zstream.avail_in) { - return NGX_AGAIN; - } else { - return NGX_OK; - } + if (ctx->out == NULL && last != NGX_NONE) { + return last; } - if (next_body_filter(r, ctx->out) == NGX_ERROR) { + last = next_body_filter(r, ctx->out); + + if (last == NGX_ERROR) { return ngx_http_gzip_error(ctx); } @@ -463,8 +456,7 @@ static void *ngx_http_gzip_create_conf(ngx_conf_t *cf) NGX_CONF_ERROR); conf->enable = NGX_CONF_UNSET; - conf->hunk_size = NGX_CONF_UNSET; - conf->hunks = NGX_CONF_UNSET; +/* conf->bufs.num = 0; */ conf->no_buffer = NGX_CONF_UNSET; return conf; @@ -478,9 +470,8 @@ static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, ngx_http_gzip_conf_t *conf = child; ngx_conf_merge_value(conf->enable, prev->enable, 0); - ngx_conf_merge_size_value(conf->hunk_size, prev->hunk_size, + ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, /* STUB: PAGE_SIZE */ 4096); - ngx_conf_merge_value(conf->hunks, prev->hunks, 4); ngx_conf_merge_value(conf->no_buffer, prev->no_buffer, 0); return NGX_CONF_OK; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 9333c954c..8be3aa341 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -101,8 +101,12 @@ static char conn_close_header[] = "Connection: close" CRLF; static int ngx_http_proxy_translate_handler(ngx_http_request_t *r) { +#if 0 r->handler = ngx_http_proxy_handler; return NGX_OK; +#else + return NGX_DECLINED; +#endif } |
