WordPress奇怪的文本覆盖json-api插件的内容 [英] Wordpress strange text over the content of json-api plugin

查看:142
本文介绍了WordPress奇怪的文本覆盖json-api插件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WordPress 4.1.1. 我试图安装 JSON API 插件.

I use WordPress 4.1.1. I tried to install the JSON API plugin.

奇怪的字母显示在JSON内容上方.并且它们在刷新页面后更新.

Strange letters are displayed above the JSON content. And they update after refresh of the page.

我试图在插件代码下再写一个字母.这些字母出现在这些数字下,那么WordPress系统中出现问题了吗?

I tried to bring another letter under the code of plugin. These letters appeared under these figures, so is the problem in the WordPress system?

请帮助我理解并删除它们,因为我无法解析JSON.

Please help me to understand and to remove them, because I can't parse my JSON.

在localhost上,可以使用相同的属性和数据正常工作...

On localhost it works fine with the same properties and data...

字母是:7b00c,78709、6eb3d ...,它们随着更新而改变..

The letter are: 7b00c, 78709, 6eb3d... and they change with updates..

推荐答案

奇怪的字符可能是chunk-size.

当服务器端进程通过HTTP服务器发送响应时,通常会将数据存储在缓冲区中,然后再传输给客户端(浏览器).如果整个响应及时放入缓冲区,服务器将在Content-Length:标头中声明大小,然后将响应原样发送给客户端.

When a server-side process sends a response through an HTTP server, the data will typically be stored in a buffer before it is transmitted to the client (browser). If the entire response fits in the buffer in a timely manner, the server will declare the size in a Content-Length: header, and send the response as-is to the client.

如果响应不适合缓冲区,或者服务器出于其他原因决定在知道完整大小之前腾出缓冲区,它将改为分块发送响应.这由Transfer-Encoding: chunked标头指示.每个块以其长度(以十六进制表示)(后跟CRLF对)开头.响应的结尾由0块大小指示.确切的语法在下面详细说明.

If the response does not fit in the buffer, or the server decides to vacate the buffer for other reasons before the full size is known, it will instead send the response in chunks. This is indicated by the Transfer-Encoding: chunked header. Each chunk is preceeded by its length in hexadecimal (followed by a CRLF-pair). The end of the response is indicated by a 0 chunk-size. The exact syntax is detailed below.

如果您自己解析HTTP响应,则需要考虑各种复杂性.块编码是其中之一.您需要检查Transfer-Encoding: chunked标头,并通过解析和剥离chunk-size部分来组装响应.

If you are parsing the HTTP response yourself, there are all sorts of intricacies that you need to consider. Chunked encoding is one of them. You need to check for the Transfer-Encoding: chunked header and assemble the response by parsing and stripping out the chunk-size parts.

使用诸如 cURL 之类的库要容易得多,它将处理所有您的详细信息.

It's much easier to use a library such as cURL which will handle all the details for you.

一种避免使用大块数据的方法是使用 HTTP/1.0 而不是 HTTP/1.1 .在HTTP/1.0中,长度由Content-Length:标头或通过关闭连接指示.

One hack to avoid chunks is to send the response using HTTP/1.0 rather than HTTP/1.1. In HTTP/1.0, the length is indicated either by the Content-Length: header, or by closing the connection.

这是 RFC 7230-超文本传输​​协议(HTTP/1.1):消息语法和路由" ( ABNF 表示法):


4.1.  Chunked Transfer Coding

     chunked-body   = *chunk
                      last-chunk
                      trailer-part
                      CRLF

     chunk          = chunk-size [ chunk-ext ] CRLF
                      chunk-data CRLF
     chunk-size     = 1*HEXDIG
     last-chunk     = 1*("0") [ chunk-ext ] CRLF

     chunk-data     = 1*OCTET ; a sequence of chunk-size octets

     trailer-part   = *( header-field CRLF )

这篇关于WordPress奇怪的文本覆盖json-api插件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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