Transfer-encoding: gzip

Magnus Naeslund
Sat, 17 Mar 2007 11:47:27 -0000

Ezra Zygmuntowicz wrote:
> Hey Magnus-
>
> 	The easiest way would be to use the mongrel deflate handler. You
> would want to add a config option for it and then at the bottom of
> merb_server.rb where I mount the mongrel handlers you woudl mount the
> deflate handler.
>

I patched merb so that I can add additional handlers in merb_init.rb, see patch
below.
In merb_init.rb i do:
Merb::Server.add_handler(:uri => ''/'', :handler =>
GzipFilter.new, :in_front => true)

If I don''t have the :in_front thing nothing happens...
The problem is that when i test it, it doesn''t compress the output, it
only sets the header:

# echo -en "GET /xxx HTTP/1.0\r\nAccept-Encoding:
gzip,deflate\r\n\r\n" | nc -v localhost 4000 | strings
localhost [127.0.0.1] 4000 (?) open
HTTP/1.1 200 OK
Connection: close
Date: Sat, 17 Mar 2007 11:45:10 GMT
Content-Encoding: gzip
Content-Type: text/html
Content-Length: 5
hello


That''s a bit strange, right?
Is there any special way I should prepare the body more than returning a string
from the controllers action?

Magnus