Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
REST Controller response in gzip compression?
  • I read the page about configuration.
    So I have set my 'ob_callback' => 'ob_gzhandler'
    And tested the REST Controller with  Chrome's Postman - REST Client

    I see response comes with header: Content-Encoding: gzip
    But the body itself is same as usual a pure json body...

    I tested with C# HttpWebRequest, I setted AutomaticDecompression to None, but it still read the json properly...

    So I think I didn't get the FuelPHP response in gzip compressed properly?
  • HarroHarro
    Accepted Answer
    Don't you think that Chome wouldn't display you the content in readable format if it was compressed?

    If you want to make sure, you can use a network sniffer like Wireshark, or use telnet:

    [wanwizard@catwoman] $ telnet localhost 80
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.

    Then type in something like:

    GET / HTTP/1.1
    host: fuel18.test.local
    Accept-Encoding: gzip

    so GET the url, enter the name of the virtual host, the accept header, en double enter after that to execute. You should see it returns a lot of garbage. If you do not add the accept header, you would see readable HTML (or json).

    p.s. to make it clear, gzip encoding only works if the client sends a "Accept-Encoding: gzip" header.

  • You are right! 
    I am missing the Accept-Encoding: gzip, I thought the response header contains Content-Encoding: gzip means its already gzip encoded.

    And I didn't know I could test it with Telnet, its worked! 
    Thanks @Harro!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion