# Gzip filter is not work with my handler

**URL:** <https://www.ruby-forum.com/t/gzip-filter-is-not-work-with-my-handler/214609>\
**Category:** NGINX\
**Created:** [December 7, 2011, 7:09am UTC](https://www.ruby-forum.com/t/gzip-filter-is-not-work-with-my-handler/214609 "2011-12-07T07:09:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 7, 2011, 7:09am UTC](https://www.ruby-forum.com/t/gzip-filter-is-not-work-with-my-handler/214609/1 "2011-12-07T07:09:16Z")

</div>

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

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

> **[gzip filter is not work with my handler](https://forum.nginx.org/read.php?2,219745,219745#msg-219745)**
>
> 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 stat

---

<div class="post-metadata">

**Author:** ![helloryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/35a633/32.png) [@helloryan](https://www.ruby-forum.com/u/helloryan)\
**Post date:** [December 7, 2011, 7:38pm UTC](https://www.ruby-forum.com/t/gzip-filter-is-not-work-with-my-handler/214609/2 "2011-12-07T19:38:47Z")

</div>

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 🙂

Posted at Nginx Forum:

> **[Re: gzip filter is not work with my handler](https://forum.nginx.org/read.php?2,219745,219771#msg-219771)**
>
> 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 stat
