comparison src/http/modules/ngx_http_gzip_filter.c @ 327:e0f3f238db09

nginx-0.0.3-2004-04-26-17:40:01 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 26 Apr 2004 13:40:01 +0000
parents 8733703a37f3
children d4241d7787fe
comparison
equal deleted inserted replaced
326:8733703a37f3 327:e0f3f238db09
589 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 589 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
590 "gzip in_hunk:" PTR_FMT " pos:" PTR_FMT, 590 "gzip in_hunk:" PTR_FMT " pos:" PTR_FMT,
591 ctx->in_hunk, ctx->in_hunk->pos); 591 ctx->in_hunk, ctx->in_hunk->pos);
592 592
593 593
594 #if 0 594 if (ctx->zstream.next_in) {
595 if (!ctx->redo) {
596 ctx->in_hunk->pos = ctx->zstream.next_in; 595 ctx->in_hunk->pos = ctx->zstream.next_in;
597 ctx->out_hunk->last = ctx->zstream.next_out; 596
598 } 597 if (ctx->zstream.avail_in == 0) {
599 #else 598 ctx->zstream.next_in = NULL;
600 ctx->in_hunk->pos = ctx->zstream.next_in; 599 }
600 }
601
601 ctx->out_hunk->last = ctx->zstream.next_out; 602 ctx->out_hunk->last = ctx->zstream.next_out;
602 #endif
603 603
604 if (ctx->zstream.avail_out == 0) { 604 if (ctx->zstream.avail_out == 0) {
605 ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool, 605 ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool,
606 ngx_http_gzip_error(ctx)); 606 ngx_http_gzip_error(ctx));
607 *ctx->last_out = cl; 607 *ctx->last_out = cl;
624 ctx->pass = 1; 624 ctx->pass = 1;
625 625
626 break; 626 break;
627 } 627 }
628 628
629 if (ctx->flush == Z_FINISH) { 629 if (rc == Z_STREAM_END) {
630
631 /* rc == Z_STREAM_END */
632 630
633 ctx->zin = ctx->zstream.total_in; 631 ctx->zin = ctx->zstream.total_in;
634 ctx->zout = 10 + ctx->zstream.total_out + 8; 632 ctx->zout = 10 + ctx->zstream.total_out + 8;
635 633
636 rc = deflateEnd(&ctx->zstream); 634 rc = deflateEnd(&ctx->zstream);
639 "deflateEnd() failed: %d", rc); 637 "deflateEnd() failed: %d", rc);
640 return ngx_http_gzip_error(ctx); 638 return ngx_http_gzip_error(ctx);
641 } 639 }
642 640
643 ngx_pfree(r->pool, ctx->preallocated); 641 ngx_pfree(r->pool, ctx->preallocated);
644
645 ctx->flush = Z_NO_FLUSH;
646 642
647 ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool, 643 ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool,
648 ngx_http_gzip_error(ctx)); 644 ngx_http_gzip_error(ctx));
649 *ctx->last_out = cl; 645 *ctx->last_out = cl;
650 ctx->last_out = &cl->next; 646 ctx->last_out = &cl->next;
714 } 710 }
715 711
716 return last; 712 return last;
717 } 713 }
718 714
719 #if 0
720 if (ctx->out == NULL && last != NGX_NONE) {
721 return last;
722 }
723 #endif
724
725 last = ngx_http_next_body_filter(r, ctx->out); 715 last = ngx_http_next_body_filter(r, ctx->out);
726 716
727 if (last == NGX_ERROR) { 717 if (last == NGX_ERROR) {
728 return ngx_http_gzip_error(ctx); 718 return ngx_http_gzip_error(ctx);
729 } 719 }
730 720
731 ngx_chain_update_chains(&ctx->free, &ctx->busy, &ctx->out, 721 ngx_chain_update_chains(&ctx->free, &ctx->busy, &ctx->out,
732 (ngx_hunk_tag_t) &ngx_http_gzip_filter_module); 722 (ngx_hunk_tag_t) &ngx_http_gzip_filter_module);
733 ctx->last_out = &ctx->out; 723 ctx->last_out = &ctx->out;
724
725 if (ctx->done) {
726 return last;
727 }
734 } 728 }
735 } 729 }
736 730
737 731
738 static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) 732 static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)