Decoding chunked HTTP with Actionscript

2019-02-16 03:12发布

I have successfully connected to an HTTP server with ActionScript 3 over sockets. The only problem is, the server is sending chunked HTTP. Is there a generic function in any other language I can look at that clearly shows how to decode the chunking? I'm pretty sure there are no ActionScript libraries around for this.

1条回答
女痞
2楼-- · 2019-02-16 03:32

The HTTP 1.1 specification (or from W3C) provides a pseudocode example of how to decode chunked transfer-coding:

length := 0
read chunk-size, chunk-extension (if any) and CRLF
while (chunk-size > 0) {
   read chunk-data and CRLF
   append chunk-data to entity-body
   length := length + chunk-size
   read chunk-size and CRLF
}
read entity-header
while (entity-header not empty) {
   append entity-header to existing header fields
   read entity-header
}
Content-Length := length
Remove "chunked" from Transfer-Encoding
查看更多
登录 后发表回答