comparison src/http/ngx_http_file_cache.c @ 642:d3cf6c6b0043 NGINX_1_1_5

nginx 1.1.5 *) Feature: the "uwsgi_buffering" and "scgi_buffering" directives. Thanks to Peter Smit. *) Bugfix: non-cacheable responses might be cached if "proxy_cache_bypass" directive was used. Thanks to John Ferlito. *) Bugfix: in HTTP/1.1 support in the ngx_http_proxy_module. *) Bugfix: cached responses with an empty body were returned incorrectly; the bug had appeared in 0.8.31. *) Bugfix: 201 responses of the ngx_http_dav_module were incorrect; the bug had appeared in 0.8.32. *) Bugfix: in the "return" directive. *) Bugfix: the "ssl_session_cache builtin" directive caused segmentation fault; the bug had appeared in 1.1.1.
author Igor Sysoev <http://sysoev.ru>
date Wed, 05 Oct 2011 00:00:00 +0400
parents 943566b4d82e
children 753f505670e0
comparison
equal deleted inserted replaced
641:6c19b251b926 642:d3cf6c6b0043
851 c = r->cache; 851 c = r->cache;
852 852
853 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 853 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
854 "http file cache send: %s", c->file.name.data); 854 "http file cache send: %s", c->file.name.data);
855 855
856 if (r != r->main && c->length - c->body_start == 0) {
857 return ngx_http_send_header(r);
858 }
859
856 /* we need to allocate all before the header would be sent */ 860 /* we need to allocate all before the header would be sent */
857 861
858 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); 862 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
859 if (b == NULL) { 863 if (b == NULL) {
860 return NGX_HTTP_INTERNAL_SERVER_ERROR; 864 return NGX_HTTP_INTERNAL_SERVER_ERROR;
863 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)); 867 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
864 if (b->file == NULL) { 868 if (b->file == NULL) {
865 return NGX_HTTP_INTERNAL_SERVER_ERROR; 869 return NGX_HTTP_INTERNAL_SERVER_ERROR;
866 } 870 }
867 871
868 r->header_only = (c->length - c->body_start) == 0;
869
870 rc = ngx_http_send_header(r); 872 rc = ngx_http_send_header(r);
871 873
872 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { 874 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
873 return rc; 875 return rc;
874 } 876 }
875 877
876 b->file_pos = c->body_start; 878 b->file_pos = c->body_start;
877 b->file_last = c->length; 879 b->file_last = c->length;
878 880
879 b->in_file = 1; 881 b->in_file = (c->length - c->body_start) ? 1: 0;
880 b->last_buf = (r == r->main) ? 1: 0; 882 b->last_buf = (r == r->main) ? 1: 0;
881 b->last_in_chain = 1; 883 b->last_in_chain = 1;
882 884
883 b->file->fd = c->file.fd; 885 b->file->fd = c->file.fd;
884 b->file->name = c->file.name; 886 b->file->name = c->file.name;