JSON REST Service: Content-Encoding: gzip

I am writing some code for interacting with a service that I do not have yet, so I am writing a simulator to try to remove the risk with some of the problems that I might encounter when I have the opportunity to integrate with a real system. An interface is basically a REST style interface that returns strings in JSON format.
The interface specification says that a formatted JSON response is returned instead of the standard HTTP body. It also says that responses from the server will be zlib-compressed and will have “Content-Encoding: gzip” in the header. So I created a WCF service that provides a REST interface that returns a formatted JSON string. Now I need to deal with the compression part of the equation. To satisfy the requirements of Content-Encoding: gzip, is it just gzip that the JSON string I created is simple and returns it, not a string? Or is it more related to this? Let me know if there is any other information that is needed here as I am still new to working with REST / HTTP.

Thanks so much for your time.

+2
source share
2 answers

You're right. Just gzip the json string and return it.

The best link for any REST implementation is the HTTP / 1.1 RFC: http://tools.ietf.org/html/rfc2616

+3
source

In short: yes, it's that simple. The response body simply needs to be a gzip-compressed version of the normal response body.

This question may contain some useful information for setting up your service.

+2
source

All Articles