Changeset 2a28c1
- Timestamp:
- 02/03/08 15:02:34 (4 years ago)
- Branches:
- master-v0.7, master-v0.6, memcached_gzip, upstream_count_limit
- Children:
- dbd2c3, f54237
- Parents:
- e1c857 (diff), 2bbdb3 (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@…> (02/03/08 15:02:34)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (02/03/08 15:02:34)
- Location:
- server/src/http/modules
- Files:
-
- 2 edited
-
ngx_http_gzip_filter_module.c (modified) (5 diffs)
-
ngx_http_memcached_module.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
server/src/http/modules/ngx_http_gzip_filter_module.c
r233310 r2bbdb3 319 319 320 320 if (ctx->preallocated == NULL) { 321 wbits = conf->wbits;321 wbits = (!r->gunzip ? conf->wbits : 15); 322 322 memlevel = conf->memlevel; 323 323 324 if ( ctx->length > 0) {324 if (!r->gunzip && ctx->length > 0) { 325 325 326 326 /* the actual zlib window size is smaller by 262 bytes */ … … 543 543 ctx->out_buf->last = ctx->zstream.next_out; 544 544 545 if (ctx->zstream.avail_out == 0) {546 547 /* zlib wants to output some more gzipped data */548 549 cl = ngx_alloc_chain_link(r->pool);550 if (cl == NULL) {551 ngx_http_gzip_error(ctx);552 return NGX_ERROR;553 }554 555 cl->buf = ctx->out_buf;556 cl->next = NULL;557 *ctx->last_out = cl;558 ctx->last_out = &cl->next;559 560 ctx->redo = 1;561 562 continue;563 }564 565 545 ctx->redo = 0; 566 546 567 if (ctx->flush == Z_SYNC_FLUSH 568 && ctx->out_buf->last > ctx->out_buf->pos) { 569 570 ctx->zstream.avail_out = 0; 547 if (ctx->flush == Z_SYNC_FLUSH) { 548 571 549 ctx->out_buf->flush = 1; 572 550 ctx->flush = Z_NO_FLUSH; 573 551 574 cl = ngx_alloc_chain_link(r->pool); 575 if (cl == NULL) { 576 ngx_http_gzip_error(ctx); 577 return NGX_ERROR; 578 } 579 580 cl->buf = ctx->out_buf; 581 cl->next = NULL; 582 *ctx->last_out = cl; 583 ctx->last_out = &cl->next; 584 585 break; 552 /* 553 * On decompression there might be not enough input 554 * data to produce any output data. 555 */ 556 if (ctx->out_buf->last > ctx->out_buf->pos) { 557 558 ctx->zstream.avail_out = 0; 559 560 cl = ngx_alloc_chain_link(r->pool); 561 if (cl == NULL) { 562 ngx_http_gzip_error(ctx); 563 return NGX_ERROR; 564 } 565 566 cl->buf = ctx->out_buf; 567 cl->next = NULL; 568 *ctx->last_out = cl; 569 ctx->last_out = &cl->next; 570 571 break; 572 } 586 573 } 587 574 … … 596 583 ctx->zout = ctx->zstream.total_out; 597 584 598 r->gunzip = 0;599 585 rc = inflateEnd(&ctx->zstream); 600 586 } … … 667 653 } else { 668 654 ctx->out_buf->last_buf = 1; 655 r->gunzip = 0; 669 656 } 670 657 … … 677 664 678 665 break; 666 } 667 668 if (ctx->zstream.avail_out == 0) { 669 670 /* zlib wants to output some more gzipped data */ 671 672 cl = ngx_alloc_chain_link(r->pool); 673 if (cl == NULL) { 674 ngx_http_gzip_error(ctx); 675 return NGX_ERROR; 676 } 677 678 cl->buf = ctx->out_buf; 679 cl->next = NULL; 680 *ctx->last_out = cl; 681 ctx->last_out = &cl->next; 682 683 ctx->redo = 1; 684 685 continue; 679 686 } 680 687 -
server/src/http/modules/ngx_http_memcached_module.c
r0019fc re1c857 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_CONF_TAKE1, 105 ngx_conf_set_num_slot, 106 NGX_HTTP_LOC_CONF_OFFSET, 107 offsetof(ngx_http_memcached_loc_conf_t, gzip_flag), 108 NULL }, 101 109 102 110 { ngx_string("memcached_upstream_max_fails"), … … 298 306 ngx_http_memcached_process_header(ngx_http_request_t *r) 299 307 { 300 u_char *p, * len;308 u_char *p, *beg; 301 309 ngx_str_t line; 302 310 ngx_http_upstream_t *u; 303 311 ngx_http_memcached_ctx_t *ctx; 312 ngx_http_memcached_loc_conf_t *mlcf; 313 uint32_t flags; 314 ngx_table_elt_t *h; 315 ngx_http_core_loc_conf_t *clcf; 304 316 305 317 u = r->upstream; … … 346 358 } 347 359 348 /* skip flags */349 350 while (*p ) {351 if (*p++ == ' ') { 352 goto length;353 }360 beg = p; 361 362 while (*p && *p++ != ' ') { /* void */ } 363 364 if (! *p) { 365 goto no_valid; 354 366 } 355 367 356 goto no_valid; 357 358 length: 359 360 len = p; 368 flags = ngx_atoof(beg, p - beg - 1); 369 370 beg = p; 361 371 362 372 while (*p && *p++ != CR) { /* void */ } 363 373 364 r->headers_out.content_length_n = ngx_atoof( len, p - len- 1);374 r->headers_out.content_length_n = ngx_atoof(beg, p - beg - 1); 365 375 if (r->headers_out.content_length_n == -1) { 366 376 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, … … 369 379 &line, &ctx->key); 370 380 return NGX_HTTP_UPSTREAM_INVALID_HEADER; 381 } 382 383 mlcf = ngx_http_get_module_loc_conf(r, ngx_http_memcached_module); 384 385 if (flags & mlcf->gzip_flag) { 386 #if (NGX_HTTP_GZIP) 387 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 388 389 if (ngx_http_gzip_ok(r) == NGX_OK) { 390 h = ngx_list_push(&r->headers_out.headers); 391 if (h == NULL) { 392 return NGX_ERROR; 393 } 394 395 h->hash = 1; 396 h->key.len = sizeof("Content-Encoding") - 1; 397 h->key.data = (u_char *) "Content-Encoding"; 398 h->value.len = sizeof("gzip") - 1; 399 h->value.data = (u_char *) "gzip"; 400 401 r->headers_out.content_encoding = h; 402 403 if (clcf->gzip_vary) { 404 h = ngx_list_push(&r->headers_out.headers); 405 if (h == NULL) { 406 return NGX_ERROR; 407 } 408 409 h->hash = 1; 410 h->key.len = sizeof("Vary") - 1; 411 h->key.data = (u_char *) "Vary"; 412 h->value.len = sizeof("Accept-Encoding") - 1; 413 h->value.data = (u_char *) "Accept-Encoding"; 414 } 415 } else { 416 if (clcf->gunzip) { 417 r->gunzip = 1; 418 } else { 419 #endif 420 /* 421 * If the client can't accept compressed data, and 422 * automatic decompression is not enabled, we 423 * return 404 in the hope that the next upstream 424 * will return uncompressed data. 425 */ 426 u->headers_in.status_n = 404; 427 u->state->status = 404; 428 429 return NGX_OK; 430 #if (NGX_HTTP_GZIP) 431 } 432 } 433 #endif 371 434 } 372 435 … … 532 595 533 596 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; 597 598 conf->gzip_flag = NGX_CONF_UNSET_UINT; 534 599 535 600 /* the hardcoded values */ … … 576 641 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); 577 642 643 ngx_conf_merge_uint_value(conf->gzip_flag, 644 prev->gzip_flag, 0); 645 578 646 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { 579 647 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
Note: See TracChangeset
for help on using the changeset viewer.
