1. Laurence Rowe
  2. nginx-xslt-html-parser

Commits

Laurence Rowe  committed 1a21700

Handle empty response body

Responses, and especially proxied responses, may have empty bodies. These
should pass through the filter without causing an internal server error or
crashing nginx.

Example config:

location = /testme {
default_type text/xml;
return 204;
xslt_stylesheet example.xsl;
}

  • Participants
  • Parent commits 65fd489
  • Branches default

Comments (0)

Files changed (1)

File src/http/modules/ngx_http_xslt_filter_module.c

View file
  • Ignore whitespace
 
         if (cl->buf->last_buf || cl->buf->last_in_chain) {
 
+            if (ctx->ctxt == NULL) {
+                /* empty body */
+                return ngx_http_next_header_filter(r);
+            }
+
             ctx->doc = ctx->ctxt->myDoc;
 
 #if (NGX_HTTP_XSLT_REUSE_DTD)
-            ctx->doc->extSubset = NULL;
+            if (ctx->doc) {
+                ctx->doc->extSubset = NULL;
+            }
 #endif
 
             wellFormed = ctx->ctxt->wellFormed;
 
     if (ctx->ctxt == NULL) {
 
+        if (b->last == b->pos) {
+            return NGX_OK;
+        }
+
         if (ctx->html_parser) {
             if (r->headers_out.charset.len) {
                 enc = xmlParseCharEncoding(