gzip filter is not work with my handler

helloryan nginx-forum at nginx.us
Wed Dec 7 06:08:52 UTC 2011

I wrote a very simple nginx handler,just output some text (size  100B to

the code works properly with nginx( ver 1.0.6)

but I found gzip filter can not work with the handler .

when I turn gzip on in nginx.conf, the gzip works file with static html

but, the handler's response is not compressed with gzip.

after a lot of search job, I still  can not find the answer.

any comments ? thanks a lot. :-)

//my code :
static ngx_int_t ngx_http_test_handler(ngx_http_request_t *r){
    ngx_chain_t  out;
    ngx_buf_t   *b;

    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));

    //writing text to buffer
     r->headers_out.status = NGX_HTTP_OK;
     r->headers_out.content_length_n = len;
     r->headers_out.content_type.len = sizeof("text/html")-1;
     r->headers_out.content_type.data = (u_char *) "text/html";

    out.buf = b;
    out.next = NULL;
    return ngx_http_output_filter(r, &out);

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,219745,219745#msg-219745

More information about the nginx mailing list