changeset 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 e21f3b073843
files src/http/modules/ngx_http_xslt_filter_module.c
diffstat 1 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_xslt_filter_module.c
+++ b/src/http/modules/ngx_http_xslt_filter_module.c
@@ -332,11 +332,15 @@ ngx_http_xslt_send(ngx_http_request_t *r
                                                NGX_HTTP_INTERNAL_SERVER_ERROR);
     }
 
-    r->headers_out.content_length_n = b->last - b->pos;
+    if (r == r->main) {
+        r->headers_out.content_length_n = b->last - b->pos;
 
-    if (r->headers_out.content_length) {
-        r->headers_out.content_length->hash = 0;
-        r->headers_out.content_length = NULL;
+        if (r->headers_out.content_length) {
+            r->headers_out.content_length->hash = 0;
+            r->headers_out.content_length = NULL;
+        }
+
+        ngx_http_clear_last_modified(r);
     }
 
     rc = ngx_http_next_header_filter(r);
@@ -785,7 +789,13 @@ ngx_http_xslt_apply_stylesheet(ngx_http_
 
     /* there must be at least one stylesheet */
 
-    type = ngx_http_xslt_content_type(sheet[i - 1].stylesheet);
+    if (r == r->main) {
+        type = ngx_http_xslt_content_type(sheet[i - 1].stylesheet);
+
+    } else {
+        type = NULL;
+    }
+
     encoding = ngx_http_xslt_encoding(sheet[i - 1].stylesheet);
     doc_type = doc->type;
 
@@ -821,6 +831,15 @@ ngx_http_xslt_apply_stylesheet(ngx_http_
     b->memory = 1;
     b->last_buf = 1;
 
+    if (encoding) {
+        r->headers_out.charset.len = ngx_strlen(encoding);
+        r->headers_out.charset.data = encoding;
+    }
+
+    if (r != r->main) {
+        return b;
+    }
+
     if (type) {
         len = ngx_strlen(type);
 
@@ -835,11 +854,6 @@ ngx_http_xslt_apply_stylesheet(ngx_http_
         r->headers_out.content_type.data = (u_char *) "text/html";
     }
 
-    if (encoding) {
-        r->headers_out.charset.len = ngx_strlen(encoding);
-        r->headers_out.charset.data = encoding;
-    }
-
     return b;
 }