3

I am writing some code to interface with a service that I do not have yet, so I am writing a simulator to attempt to de-risk some of the problems I might run into when I get a chance to integrate against the real system. The interface is basically a REST style interface that returns JSON formatted strings.
The interface specification says the JSON formatted response is returned in lieu of the standard HTTP body. It also says that responses from the server will be zlib compressed and have the "Content-Encoding: gzip" set in the header. So I created a WCF service that provides a REST interface that returns a JSON formatted string. I now need to deal with the compression portion of the equation. To satisfy the Content-Encoding: gzip requirements, do I simply gzip the JSON string I created and return that rather than the string? Or is it more involved than that? Let me know if there is any other information that is needed here, as I am still a newbie when dealing with REST/HTTP.

Thanks so Much for your time.

2
  • I don't think you need to do it manually as others have suggested. Check out posts like this one: stackoverflow.com/questions/1402295/wcf-rest-compression Commented Dec 13, 2011 at 20:55
  • What would be the return type if I am returning the gzipped JSON string? Commented Feb 23, 2012 at 18:30

2 Answers 2

4

You're correct. Just Gzip the JSON string and return it.

Best reference for any REST implementation is the HTTP/1.1 RFC: https://www.rfc-editor.org/rfc/rfc2616

Sign up to request clarification or add additional context in comments.

Comments

3

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.