Changeset 56389f
- Timestamp:
- 04/13/08 13:19:54 (4 years ago)
- Branches:
- master-v0.7, master-v0.6, memcached_gzip, upstream_count_limit
- Children:
- f54237
- Parents:
- b3076c (diff), 21b759 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Tomash Brechko <tomash.brechko@…> (04/13/08 13:19:54)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (04/13/08 13:19:54)
- Location:
- server/src/http/modules
- Files:
-
- 2 edited
-
ngx_http_gzip_filter_module.c (modified) (1 diff)
-
ngx_http_memcached_module.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
server/src/http/modules/ngx_http_gzip_filter_module.c
r95d817 r21b759 629 629 * On decompression we could already output everything 630 630 * under (ctx->flush == Z_SYNC_FLUSH), so we test here 631 * that the buffer is not empty. 631 * that the buffer is not empty, or Transfer-Encoding: 632 * is chunked. In the latter case we output empty 633 * buffer to get last zero length chunk. 632 634 */ 633 if (!r->gunzip || ctx->out_buf->last > ctx->out_buf->pos) { 635 if (!r->gunzip || ctx->out_buf->last > ctx->out_buf->pos 636 || r->chunked) { 634 637 cl->buf = ctx->out_buf; 635 638 cl->next = NULL; -
server/src/http/modules/ngx_http_memcached_module.c
r0019fc rb3076c 14 14 ngx_http_upstream_conf_t upstream; 15 15 ngx_int_t index; 16 ngx_uint_t gzip_flag; 16 17 } ngx_http_memcached_loc_conf_t; 17 18 … … 99 100 offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream), 100 101 &ngx_http_memcached_next_upstream_masks }, 102 103 { ngx_string("memcached_gzip_flag"), 104 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF 105 |NGX_CONF_TAKE1, 106 ngx_conf_set_num_slot, 107 NGX_HTTP_LOC_CONF_OFFSET, 108 offsetof(ngx_http_memcached_loc_conf_t, gzip_flag), 109 NULL }, 101 110 102 111 { ngx_string("memcached_upstream_max_fails"), … … 298 307 ngx_http_memcached_process_header(ngx_http_request_t *r) 299 308 { 300 u_char *p, * len;309 u_char *p, *beg; 301 310 ngx_str_t line; 302 311 ngx_http_upstream_t *u; 303 312 ngx_http_memcached_ctx_t *ctx; 313 ngx_http_memcached_loc_conf_t *mlcf; 314 uint32_t flags; 315 ngx_table_elt_t *h; 316 ngx_http_core_loc_conf_t *clcf; 304 317 305 318 u = r->upstream; … … 346 359 } 347 360 348 /* skip flags */349 350 while (*p ) {351 if (*p++ == ' ') { 352 goto length;353 }361 beg = p; 362 363 while (*p && *p++ != ' ') { /* void */ } 364 365 if (! *p) { 366 goto no_valid; 354 367 } 355 368 356 goto no_valid; 357 358 length: 359 360 len = p; 369 flags = ngx_atoof(beg, p - beg - 1); 370 371 beg = p; 361 372 362 373 while (*p && *p++ != CR) { /* void */ } 363 374 364 r->headers_out.content_length_n = ngx_atoof( len, p - len- 1);375 r->headers_out.content_length_n = ngx_atoof(beg, p - beg - 1); 365 376 if (r->headers_out.content_length_n == -1) { 366 377 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, … … 369 380 &line, &ctx->key); 370 381 return NGX_HTTP_UPSTREAM_INVALID_HEADER; 382 } 383 384 mlcf = ngx_http_get_module_loc_conf(r, ngx_http_memcached_module); 385 386 if (flags & mlcf->gzip_flag) { 387 #if (NGX_HTTP_GZIP) 388 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 389 390 if (ngx_http_gzip_ok(r) == NGX_OK) { 391 h = ngx_list_push(&r->headers_out.headers); 392 if (h == NULL) { 393 return NGX_ERROR; 394 } 395 396 h->hash = 1; 397 h->key.len = sizeof("Content-Encoding") - 1; 398 h->key.data = (u_char *) "Content-Encoding"; 399 h->value.len = sizeof("gzip") - 1; 400 h->value.data = (u_char *) "gzip"; 401 402 r->headers_out.content_encoding = h; 403 404 if (clcf->gzip_vary) { 405 h = ngx_list_push(&r->headers_out.headers); 406 if (h == NULL) { 407 return NGX_ERROR; 408 } 409 410 h->hash = 1; 411 h->key.len = sizeof("Vary") - 1; 412 h->key.data = (u_char *) "Vary"; 413 h->value.len = sizeof("Accept-Encoding") - 1; 414 h->value.data = (u_char *) "Accept-Encoding"; 415 } 416 } else { 417 if (clcf->gunzip) { 418 r->gunzip = 1; 419 } else { 420 #endif 421 /* 422 * If the client can't accept compressed data, and 423 * automatic decompression is not enabled, we 424 * return 404 in the hope that the next upstream 425 * will return uncompressed data. 426 */ 427 u->headers_in.status_n = 404; 428 u->state->status = 404; 429 430 return NGX_OK; 431 #if (NGX_HTTP_GZIP) 432 } 433 } 434 #endif 371 435 } 372 436 … … 532 596 533 597 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; 598 599 conf->gzip_flag = NGX_CONF_UNSET_UINT; 534 600 535 601 /* the hardcoded values */ … … 576 642 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); 577 643 644 ngx_conf_merge_uint_value(conf->gzip_flag, 645 prev->gzip_flag, 0); 646 578 647 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { 579 648 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
Note: See TracChangeset
for help on using the changeset viewer.
