duanlei4759 2011-02-11 07:10
浏览 23
已采纳

too long

the result of reponse is like this

HTTP/1.1 200 OK
Date: Fri, 11 Feb 2011 06:59:47 GMT
Server: Apache
Set-Cookie: id%22%3Bs%3A32%3A%223c38c56b3def2530014336c922ee0bfc%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A14%3A%2269.162.119.226%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A0%3A%22%22%3Bs%3A13%3A%22last_activity%22%3Bs%3A10%3A%221297407587%22%3B%7Dcd356ca12b8d395b49603cb3eb34f786; expires=Fri, 11-Feb-2011 08:59:47 GMT; path=/ Set-Cookie: vaave_session=a%3A3Bs%3A32%3A%223c38c56b3def2530014336c922ee0bfc%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A14%3A%2269.162.119.226%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A0%3A%22%22%3Bs%3A13%3A%22last_activity%22%3Bs%3A10%3A%221297407587%22%3Bs%3A2%3A%22tz%22%3Bs%3A13%3A%22Asia%2FCalcutta%22%3B%7Daadf6cb5ad21eae3c04e24cf00b3ea16; expires=Fri, 11-Feb-2011 08:59:47 GMT; path=/ 
Connection: close
Transfer-Encoding: chunked

"data here"
  • 写回答

1条回答 默认 最新

  • douba4275 2011-02-11 07:24
    关注

    The data is transmitted in "chunks", i.e. a block of bytes that's preceded by its length. To quote Wikipedia's example:

    HTTP/1.1 200 OK
    Content-Type: text/plain
    Transfer-Encoding: chunked
    
    25
    This is the data in the first chunk
    
    1C
    and this is the second one
    
    3
    con
    8
    sequence
    0
    

    The only relevant header here is Transfer-Encoding: chunked. You'll see that there is a hex number on the first line. That tells you how many bytes to expect in the following chunk - 25 in hex is 37 in decimal, and sure enough, there's a linebreak after 37 chars, followed by another hex number with the byte count of the following chunk, and so on until the end - the last chunk size MUST be 0, signifying end of data. (The chunk sizes are not part of the content). The decoded message would be this:

    This is the data in the first chunk
    and this is the second one
    consequence
    

    Edit: It seems that there is an existing function in PECL for this, http_chunked_decode() - and there's a pure PHP implementation on that page, too - just pass it the chunked data, and it will try to "unchunk" it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置