Why does the HTTP response body contain “2fb” at t

2019-07-19 09:55发布

I am doing some API requests using fsockopen() in PHP. For most APIs that works correctly, but from http://geocoding.cloudmade.com/ I get the following (RAW) response:

HTTP/1.1 200 OK
Server: nginx/0.6.35
cache-control: no-cache
Content-Type: application/json; charset=utf-8
Date: Tue, 19 Feb 2013 11:08:05 GMT
pragma: no-cache
Transfer-Encoding: chunked
Connection: close

2fb
{"found": 1, "bounds": [[52.48732, 13.42553], ...
0

My problem is that "2fb" in the first line and the "0" in the last line of the body does not tell my anything. If I send the same request via Firefox, the body does not contain a "2fb" or "0". Therefore, I guess it has some meaning. But what?

Thanks for hints!

标签: php api http
1条回答
别忘想泡老子
2楼-- · 2019-07-19 10:17

That is chunked transfer-coding, also indicated by the Transfer-Encoding: chunked response header:

The chunked encoding modifies the body of a message in order to transfer it as a series of chunks, each with its own size indicator, followed by an OPTIONAL trailer containing entity-header fields. This allows dynamically produced content to be transferred along with the information necessary for the recipient to verify that it has received the full message.

2fb, followed by \r\n, indicates the size of the following chunk (763 bytes). A chunk-size of 0 indicates the last chunk.

查看更多
登录 后发表回答