'Parsing chunked HTTP payload from TCP stream

I have a TCP stream (NetworkStream) with chunked HTTP payload. First bytes in the stream represent a response header (HTTP/1.1 200....) \r\n\r\n. Then a stream of chunked HTTP messages (HEX \r\n, <bytes>\r\n).

What I need is this method:

public Stream TcpToHttp GetHttpData(NetworkStream tcpStream);

The method will read the TCP stream and parse the byte array to HTTP response. Is there an easy way to implement this? I am trying to refrain implementing an HTTP parser.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source