comparison src/http/modules/ngx_http_gzip_filter.c @ 166:389d7ee9fa60

nginx-0.0.1-2003-10-30-11:51:06 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 30 Oct 2003 08:51:06 +0000
parents 894a01c6aea3
children 4db54fdbcbe7
comparison
equal deleted inserted replaced
165:894a01c6aea3 166:389d7ee9fa60
188 188
189 ngx_http_create_ctx(r, ctx, ngx_http_gzip_filter_module, 189 ngx_http_create_ctx(r, ctx, ngx_http_gzip_filter_module,
190 sizeof(ngx_http_gzip_ctx_t), NGX_ERROR); 190 sizeof(ngx_http_gzip_ctx_t), NGX_ERROR);
191 ctx->request = r; 191 ctx->request = r;
192 192
193 if (!(r->headers_out.content_encoding = 193 r->headers_out.content_encoding =
194 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) 194 ngx_http_add_header(&r->headers_out, ngx_http_headers_out);
195 { 195 if (r->headers_out.content_encoding == NULL) {
196 return NGX_ERROR; 196 return NGX_ERROR;
197 } 197 }
198 198
199 r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1; 199 r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1;
200 r->headers_out.content_encoding->key.data = "Content-Encoding"; 200 r->headers_out.content_encoding->key.data = "Content-Encoding";
220 ngx_hunk_t *h; 220 ngx_hunk_t *h;
221 ngx_chain_t *cl; 221 ngx_chain_t *cl;
222 ngx_http_gzip_ctx_t *ctx; 222 ngx_http_gzip_ctx_t *ctx;
223 ngx_http_gzip_conf_t *conf; 223 ngx_http_gzip_conf_t *conf;
224 224
225 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); 225 if (!(ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module))) {
226
227 if (ctx == NULL) {
228 return ngx_http_next_body_filter(r, in); 226 return ngx_http_next_body_filter(r, in);
229 } 227 }
230 228
231 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); 229 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module);
232 230
342 ctx->out_hunk = ctx->free->hunk; 340 ctx->out_hunk = ctx->free->hunk;
343 ctx->free = ctx->free->next; 341 ctx->free = ctx->free->next;
344 342
345 } else if (ctx->hunks < conf->bufs.num) { 343 } else if (ctx->hunks < conf->bufs.num) {
346 ngx_test_null(ctx->out_hunk, 344 ngx_test_null(ctx->out_hunk,
347 ngx_create_temp_hunk(r->pool, conf->bufs.size, 345 ngx_create_temp_hunk(r->pool, conf->bufs.size),
348 0, 0), 346 ngx_http_gzip_error(ctx));
349 ngx_http_gzip_error(ctx));
350 ctx->out_hunk->tag = (ngx_hunk_tag_t) 347 ctx->out_hunk->tag = (ngx_hunk_tag_t)
351 &ngx_http_gzip_filter_module; 348 &ngx_http_gzip_filter_module;
352 ctx->out_hunk->type |= NGX_HUNK_RECYCLED; 349 ctx->out_hunk->type |= NGX_HUNK_RECYCLED;
353 ctx->hunks++; 350 ctx->hunks++;
354 351
427 ctx->out_hunk->type |= NGX_HUNK_LAST; 424 ctx->out_hunk->type |= NGX_HUNK_LAST;
428 ctx->out_hunk->last += 8; 425 ctx->out_hunk->last += 8;
429 426
430 } else { 427 } else {
431 ngx_test_null(h, 428 ngx_test_null(h,
432 ngx_create_temp_hunk(r->pool, 8, 0, 0), 429 ngx_create_temp_hunk(r->pool, 8),
433 ngx_http_gzip_error(ctx)); 430 ngx_http_gzip_error(ctx));
434 431
435 h->type |= NGX_HUNK_LAST; 432 h->type |= NGX_HUNK_LAST;
436 433
437 ngx_alloc_link_and_set_hunk(cl, h, r->pool, 434 ngx_alloc_link_and_set_hunk(cl, h, r->pool,