【问题标题】:special characters inserted in https json return string在 https json 返回字符串中插入的特殊字符
【发布时间】:2012-04-05 20:27:38
【问题描述】:

使用 curl 获取 JSON 字符串时,我的 json 字符串中出现了一些奇怪的字符。这些字符在 HEX 中是“0d 0a 32 30 30 30 0d 0a”,它们在返回的 JSON 字符串中重复多次。我正在使用带有 Nginx 的 https、rails 服务器。但是,如果我将 rails 服务器与另一个 Web 服务器(如 Webrick)一起使用,我就没有这样的问题。

curl --trace 输出

1c60: 6c 65 66 74 5f 63 6f 72 6e 65 72 22 3a 6e 75 6c left_corner":nul
1c70: 6c 2c 22 6c 65 0d 0a 32 30 30 30 0d 0a 66 74 5f l,"le..2000..ft_
1c80: 68 65 69 67 68 74 22 3a 6e 75 6c 6c 2c 22 72 69 height":null,"ri

curl --trace-ascii 输出

1c46: eft_leg_child_size":null,"left_corner":null,"le
1c77: 2000
1c7d: ft_height":null,

【问题讨论】:

    标签: ruby-on-rails json curl https nginx


    【解决方案1】:

    响应是否有 Transfer-Encoding: chunked 标头?看起来它可能是一个块长度标签。

    【讨论】:

    • 它在响应头中有“Transfer-Encoding: chunked”
    • 你用的是什么客户端? http/1.1 客户端需要处理分块编码。
    猜你喜欢
    • 2017-05-05
    • 2011-06-10
    • 1970-01-01
    • 2016-11-24
    • 2015-07-07
    • 1970-01-01
    • 1970-01-01
    • 2011-10-28
    • 1970-01-01
    相关资源
    最近更新 更多