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.
Raw TCP is a business requirement that I need to keep, therefore I can’t switch to .NET HTTPWebRequest/HTTPWebResponse However if there is way to convert a RAW HTTP Request/Response into HTTPWebRequest/HTTPWebResponse that’d work.
The best place to start is the http 1.1 specification, which lays out how chunking works. Specifically section 3.6.1.
Assuming that you have already read the header from the response and are pointing to the next byte in the stream your pseudo code would look something like this:
This is ignoring the chunk-extension portion, but since it is delimited with a ‘;’ it should be easy to split it out. This should be enough to get you started. Keep in mind that the chunksize string does not have a leading ‘0x’.