Chunked Encoding Implementation in .NET (or at least pseudo code)

前端 未结 2 1451
半阙折子戏
半阙折子戏 2020-12-15 15:27

I wrote a raw TCP client for HTTP/HTTPS requests, however I\'m having problems with chunked encoding responses. HTTP/1.1 is requirement therefore I should support it.

<
2条回答
  •  长情又很酷
    2020-12-15 15:48

    For the future reference also I found this :

     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
    

提交回复
热议问题