Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_gzip_filter.c @ 315:39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 14 Apr 2004 17:44:28 +0000 |
parents | d71c87d11b16 |
children | 7a8ebba985a9 |
comparison
equal
deleted
inserted
replaced
314:d71c87d11b16 | 315:39b6f2df45c0 |
---|---|
94 }; | 94 }; |
95 | 95 |
96 | 96 |
97 static ngx_conf_enum_t ngx_http_gzip_proxied[] = { | 97 static ngx_conf_enum_t ngx_http_gzip_proxied[] = { |
98 { ngx_string("off"), NGX_HTTP_GZIP_PROXIED_OFF }, | 98 { ngx_string("off"), NGX_HTTP_GZIP_PROXIED_OFF }, |
99 #if 0 | |
100 { ngx_string("nocachable"), NGX_HTTP_GZIP_PROXIED_NOCACHABLE }, | 99 { ngx_string("nocachable"), NGX_HTTP_GZIP_PROXIED_NOCACHABLE }, |
101 { ngx_string("poor_cachable"), NGX_HTTP_GZIP_PROXIED_POOR_CACHABLE }, | 100 { ngx_string("poor_cachable"), NGX_HTTP_GZIP_PROXIED_POOR_CACHABLE }, |
102 #endif | |
103 { ngx_string("on"), NGX_HTTP_GZIP_PROXIED_ON }, | 101 { ngx_string("on"), NGX_HTTP_GZIP_PROXIED_ON }, |
104 { ngx_null_string, 0 } | 102 { ngx_null_string, 0 } |
105 }; | 103 }; |
106 | 104 |
107 | 105 |
221 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; | 219 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
222 | 220 |
223 | 221 |
224 static int ngx_http_gzip_header_filter(ngx_http_request_t *r) | 222 static int ngx_http_gzip_header_filter(ngx_http_request_t *r) |
225 { | 223 { |
224 time_t date, expires; | |
226 ngx_http_gzip_ctx_t *ctx; | 225 ngx_http_gzip_ctx_t *ctx; |
227 ngx_http_gzip_conf_t *conf; | 226 ngx_http_gzip_conf_t *conf; |
228 | 227 |
229 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); | 228 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); |
230 | 229 |
248 { | 247 { |
249 return ngx_http_next_header_filter(r); | 248 return ngx_http_next_header_filter(r); |
250 } | 249 } |
251 | 250 |
252 | 251 |
253 /* TODO: proxied */ | 252 if (r->headers_in.via && conf->proxied != NGX_HTTP_GZIP_PROXIED_ON) { |
254 if (r->headers_in.via && conf->proxied == NGX_HTTP_GZIP_PROXIED_OFF) { | 253 |
255 return ngx_http_next_header_filter(r); | 254 if (conf->proxied == NGX_HTTP_GZIP_PROXIED_OFF) { |
255 return ngx_http_next_header_filter(r); | |
256 } | |
257 | |
258 if (r->headers_out.expires) { | |
259 expires = ngx_http_parse_time(r->headers_out.expires->value.data, | |
260 r->headers_out.expires->value.len); | |
261 if (expires == NGX_ERROR) { | |
262 return ngx_http_next_header_filter(r); | |
263 } | |
264 | |
265 if (r->headers_out.date) { | |
266 date = ngx_http_parse_time(r->headers_out.date->value.data, | |
267 r->headers_out.date->value.len); | |
268 if (date == NGX_ERROR) { | |
269 return ngx_http_next_header_filter(r); | |
270 } | |
271 | |
272 } else { | |
273 date = ngx_cached_time; | |
274 } | |
275 | |
276 if (expires >= date) { | |
277 return ngx_http_next_header_filter(r); | |
278 } | |
279 | |
280 } else if (r->headers_out.cache_control) { | |
281 | |
282 if (conf->proxied == NGX_HTTP_GZIP_PROXIED_NOCACHABLE) { | |
283 if (ngx_strstr(r->headers_out.cache_control->value.data, | |
284 "no-cache") == NULL) | |
285 { | |
286 return ngx_http_next_header_filter(r); | |
287 } | |
288 | |
289 } else { /* NGX_HTTP_GZIP_PROXIED_POOR_CACHABLE */ | |
290 | |
291 /* STUB: should be one cycle for all values */ | |
292 | |
293 if (ngx_strstr(r->headers_out.cache_control->value.data, | |
294 "no-cache") == NULL | |
295 && ngx_strstr(r->headers_out.cache_control->value.data, | |
296 "private") == NULL | |
297 && ngx_strstr(r->headers_out.cache_control->value.data, | |
298 "no-store") == NULL) | |
299 { | |
300 return ngx_http_next_header_filter(r); | |
301 } | |
302 } | |
303 | |
304 } else if (conf->proxied == NGX_HTTP_GZIP_PROXIED_NOCACHABLE) { | |
305 return ngx_http_next_header_filter(r); | |
306 | |
307 } else { /* NGX_HTTP_GZIP_PROXIED_POOR_CACHABLE */ | |
308 | |
309 if (r->headers_out.last_modified || r->headers_out.etag) { | |
310 return ngx_http_next_header_filter(r); | |
311 } | |
312 } | |
256 } | 313 } |
257 | 314 |
258 | 315 |
259 /* | 316 /* |
260 * if the URL (without the "http://" prefix) is longer than 253 bytes | 317 * if the URL (without the "http://" prefix) is longer than 253 bytes |
531 | 588 |
532 #if (HAVE_LITTLE_ENDIAN) | 589 #if (HAVE_LITTLE_ENDIAN) |
533 trailer->crc32 = ctx->crc32; | 590 trailer->crc32 = ctx->crc32; |
534 trailer->zlen = ctx->zin; | 591 trailer->zlen = ctx->zin; |
535 #else | 592 #else |
536 /* STUB */ | 593 /* STUB */ Oops ! |
537 #endif | 594 #endif |
538 | 595 |
539 ctx->zstream.avail_in = 0; | 596 ctx->zstream.avail_in = 0; |
540 ctx->zstream.avail_out = 0; | 597 ctx->zstream.avail_out = 0; |
541 | 598 |