[mod_wsgi] header filter

Manlio Perillo manlio_perillo at libero.it
Fri Oct 19 19:07:37 MSD 2007


I'm trying to define a custom header filter in mod_wsgi, but my filter 
is not called.

Is this supported?


The filter is very simple, and I need it since Ningx does not set the 
r->header_only flag:


static
ngx_int_t ngx_http_wsgi_header_filter(ngx_http_request_t *r) {
   /*
    * A custom filter to enable cache validation in mod_wsgi.
    *
    * NOTE: this header filter SHOULD be executed after the
    * not_modified header filter.
    */

   if (r->headers_out.status != NGX_HTTP_NOT_MODIFIED) {
     return ngx_http_next_header_filter(r);
   }

   if (r->headers_out.status < NGX_HTTP_MOVED_PERMANENTLY) {
     /* 2XX */
     r->header_only = 1;

     /* XXX check me */
     r->headers_out.content_type.len = 0;
     r->headers_out.content_type.data = NULL;
     r->headers_out.last_modified_time = -1;
     r->headers_out.last_modified = NULL;
     r->headers_out.content_length = NULL;
     r->headers_out.content_length_n = -1;
   } else if (r->headers_out.status < NGX_HTTP_BAD_REQUEST) {
     r->header_only = 1;
   }

   return ngx_http_next_header_filter(r);
}



Thanks and regards  Manlio Perillo





More information about the nginx mailing list