comparison src/http/ngx_http_output_filter.c @ 153:c71aeb75c071

nginx-0.0.1-2003-10-21-20:49:56 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 21 Oct 2003 16:49:56 +0000
parents 5ac79e574285
children eac26585476e
comparison
equal deleted inserted replaced
152:fb48bf4fea1c 153:c71aeb75c071
82 || ((r->filter & NGX_HTTP_FILTER_NEED_TEMP) \ 82 || ((r->filter & NGX_HTTP_FILTER_NEED_TEMP) \
83 && (hunk->type & (NGX_HUNK_MEMORY|NGX_HUNK_MMAP))))) 83 && (hunk->type & (NGX_HUNK_MEMORY|NGX_HUNK_MMAP)))))
84 84
85 85
86 86
87 int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) 87 int ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
88 { 88 {
89 int rc, last; 89 int rc, last;
90 ssize_t size; 90 ssize_t size;
91 ngx_chain_t out, *ce, **le; 91 ngx_chain_t *ce;
92 ngx_http_output_filter_ctx_t *ctx; 92 ngx_http_output_filter_ctx_t *ctx;
93 ngx_http_output_filter_conf_t *conf; 93 ngx_http_output_filter_conf_t *conf;
94 94
95 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, 95 ctx = ngx_http_get_module_ctx(r->main ? r->main : r,
96 ngx_http_output_filter_module); 96 ngx_http_output_filter_module);
101 ctx->last_out = &ctx->out; 101 ctx->last_out = &ctx->out;
102 } 102 }
103 103
104 /* 104 /*
105 * the short path for the case when the chain ctx->in is empty 105 * the short path for the case when the chain ctx->in is empty
106 * and there's no hunk or the hunk does not require the copy 106 * and the incoming chain is empty too or it has the single hunk
107 * that does not require the copy
107 */ 108 */
108 109
109 if (ctx->in == NULL) { 110 if (ctx->in == NULL) {
110 111
111 if (hunk == NULL) { 112 if (in == NULL) {
112 return ngx_next_filter(r, NULL); 113 return ngx_next_filter(r, in);
113 } 114 }
114 115
115 if (!need_to_copy(r, hunk)) { 116 if (in->next == NULL && (!need_to_copy(r, in->hunk))) {
116 out.hunk = hunk; 117 return ngx_next_filter(r, in);
117 out.next = NULL;
118 return ngx_next_filter(r, &out);
119 } 118 }
120 } 119 }
121 120
122 /* add the incoming hunk to the chain ctx->in */ 121 /* add the incoming hunk to the chain ctx->in */
123 122
124 if (hunk) { 123 if (in) {
125 le = &ctx->in; 124 if (ngx_chain_add_copy(r->pool, &ctx->in, in) == NGX_ERROR) {
126 125 return NGX_ERROR;
127 for (ce = ctx->in; ce; ce = ce->next) { 126 }
128 le = &ce->next;
129 }
130
131 ngx_add_hunk_to_chain(ce, hunk, r->pool, NGX_ERROR);
132 *le = ce;
133 } 127 }
134 128
135 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, 129 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
136 ngx_http_output_filter_module); 130 ngx_http_output_filter_module);
137 131