Mercurial > hg > nginx
comparison src/http/modules/ngx_http_xslt_filter_module.c @ 2159:0ec936b0010a
clear Last-Modified; set content-type and length for main request only
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 06 Aug 2008 13:18:57 +0000 |
parents | 18e85d78fb0c |
children | fab3fa7339ff |
comparison
equal
deleted
inserted
replaced
2158:18e85d78fb0c | 2159:0ec936b0010a |
---|---|
330 ngx_free(b->pos); | 330 ngx_free(b->pos); |
331 return ngx_http_special_response_handler(r, | 331 return ngx_http_special_response_handler(r, |
332 NGX_HTTP_INTERNAL_SERVER_ERROR); | 332 NGX_HTTP_INTERNAL_SERVER_ERROR); |
333 } | 333 } |
334 | 334 |
335 r->headers_out.content_length_n = b->last - b->pos; | 335 if (r == r->main) { |
336 | 336 r->headers_out.content_length_n = b->last - b->pos; |
337 if (r->headers_out.content_length) { | 337 |
338 r->headers_out.content_length->hash = 0; | 338 if (r->headers_out.content_length) { |
339 r->headers_out.content_length = NULL; | 339 r->headers_out.content_length->hash = 0; |
340 r->headers_out.content_length = NULL; | |
341 } | |
342 | |
343 ngx_http_clear_last_modified(r); | |
340 } | 344 } |
341 | 345 |
342 rc = ngx_http_next_header_filter(r); | 346 rc = ngx_http_next_header_filter(r); |
343 | 347 |
344 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { | 348 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { |
783 ctx->params.nelts = 0; | 787 ctx->params.nelts = 0; |
784 } | 788 } |
785 | 789 |
786 /* there must be at least one stylesheet */ | 790 /* there must be at least one stylesheet */ |
787 | 791 |
788 type = ngx_http_xslt_content_type(sheet[i - 1].stylesheet); | 792 if (r == r->main) { |
793 type = ngx_http_xslt_content_type(sheet[i - 1].stylesheet); | |
794 | |
795 } else { | |
796 type = NULL; | |
797 } | |
798 | |
789 encoding = ngx_http_xslt_encoding(sheet[i - 1].stylesheet); | 799 encoding = ngx_http_xslt_encoding(sheet[i - 1].stylesheet); |
790 doc_type = doc->type; | 800 doc_type = doc->type; |
791 | 801 |
792 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 802 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
793 "xslt filter type: %d t:%s e:%s", | 803 "xslt filter type: %d t:%s e:%s", |
819 b->pos = buf; | 829 b->pos = buf; |
820 b->last = buf + len; | 830 b->last = buf + len; |
821 b->memory = 1; | 831 b->memory = 1; |
822 b->last_buf = 1; | 832 b->last_buf = 1; |
823 | 833 |
834 if (encoding) { | |
835 r->headers_out.charset.len = ngx_strlen(encoding); | |
836 r->headers_out.charset.data = encoding; | |
837 } | |
838 | |
839 if (r != r->main) { | |
840 return b; | |
841 } | |
842 | |
824 if (type) { | 843 if (type) { |
825 len = ngx_strlen(type); | 844 len = ngx_strlen(type); |
826 | 845 |
827 r->headers_out.content_type_len = len; | 846 r->headers_out.content_type_len = len; |
828 r->headers_out.content_type.len = len; | 847 r->headers_out.content_type.len = len; |
831 } else if (doc_type == XML_HTML_DOCUMENT_NODE) { | 850 } else if (doc_type == XML_HTML_DOCUMENT_NODE) { |
832 | 851 |
833 r->headers_out.content_type_len = sizeof("text/html") - 1; | 852 r->headers_out.content_type_len = sizeof("text/html") - 1; |
834 r->headers_out.content_type.len = sizeof("text/html") - 1; | 853 r->headers_out.content_type.len = sizeof("text/html") - 1; |
835 r->headers_out.content_type.data = (u_char *) "text/html"; | 854 r->headers_out.content_type.data = (u_char *) "text/html"; |
836 } | |
837 | |
838 if (encoding) { | |
839 r->headers_out.charset.len = ngx_strlen(encoding); | |
840 r->headers_out.charset.data = encoding; | |
841 } | 855 } |
842 | 856 |
843 return b; | 857 return b; |
844 } | 858 } |
845 | 859 |