Gzip filter is not work with my handler

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

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
files.

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. :slight_smile:

//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

nobody has some advice ?

I think handler’s response will be sent to gzip filter by nginx
automatically (gzip on), is that true?

or, I need to config something manually or make some extra coding to
call the gzip filter?

thanks for any comments :slight_smile:

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

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