Header filter

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®;
}

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®;
}

Thanks and regards Manlio P.

On Fri, Oct 19, 2007 at 05:07:37PM +0200, Manlio P. wrote:

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

Is this supported?

Yes, of course. It’s seems that your module set in filter chain too late

after ngx_htpt_header_filter_module.

If you use “config” file configuration, you need to write there:
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES
ngx_http_YOUR_filter_module"

Igor S. ha scritto:

If you use “config” file configuration, you need to write there:
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_YOUR_filter_module"

The problem is that I defined the header filter inside the wsgi
module.

Now I have defined the header filter in a separate file, and it works.

Thanks and regards Manlio P.

On Fri, Oct 19, 2007 at 06:08:55PM +0200, Manlio P. wrote:

If you use “config” file configuration, you need to write there:
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES
ngx_http_YOUR_filter_module"

The problem is that I defined the header filter inside the wsgi module.

Now I have defined the header filter in a separate file, and it works.

The filter order is defined in objs/ngx_modules.c:

&ngx_http_write_filter_module,
&ngx_http_header_filter_module,
&ngx_http_chunked_filter_module,
&ngx_http_range_header_filter_module,
&ngx_http_gzip_filter_module,
&ngx_http_postpone_filter_module,
&ngx_http_charset_filter_module,
&ngx_http_ssi_filter_module,
&ngx_http_sub_filter_module,
&ngx_http_addition_filter_module,
&ngx_http_userid_filter_module,
&ngx_http_headers_filter_module,
&ngx_http_copy_filter_module,
&ngx_http_range_body_filter_module,
&ngx_http_not_modified_filter_module,

The two filters ngx_http_range_body_filter_module and
ngx_http_range_header_filter_module are in one file, but called in
different places.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs