JSON REST服务:内容编码:gzip [英] JSON REST Service: Content-Encoding: gzip

查看:101
本文介绍了JSON REST服务:内容编码:gzip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些代码来与我尚未拥有的服务进行交互,所以我正在编写一个模拟器来尝试降低我在有机会与真实集成时遇到的一些问题的风险系统。该接口基本上是一个REST样式接口,返回JSON格式的字符串。

接口规范说,返回JSON格式的响应代替标准的HTTP主体。它还说服务器的响应将是zlib压缩并在标头中设置Content-Encoding:gzip。
所以我创建了一个WCF服务,它提供了一个返回JSON格式字符串的REST接口。我现在需要处理等式的压缩部分。为了满足Content-Encoding:gzip的要求,我只是简单地gzip我创建的JSON字符串并返回而不是字符串吗?或者它涉及的更多?如果这里需要任何其他信息,请告诉我,因为我在处理REST / HTTP时仍然是新手。

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.

非常感谢您的时间。

推荐答案

你是对的。只需Gzip JSON字符串并返回它。

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

任何REST实现的最佳参考是HTTP / 1.1 RFC: http://tools.ietf.org/html/rfc2616

Best reference for any REST implementation is the HTTP/1.1 RFC: http://tools.ietf.org/html/rfc2616

这篇关于JSON REST服务:内容编码:gzip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆