Hi All,
I'm writing an HTTP client using the .Net TcpClient / Sockets.
So far, the client handles both Content-Length and chunked responses by iterating through the NetworkStream response (after writing a GET request to the TcpClient), parsing the headers and retrieving the relevant message body bytes / chunked bytes. To do this it uses the NetworkStream ReadByte method.
This all works fine, but performance is a key consideration of the application so I would like to make it as quick and efficient as possible.
Initially this will involve swapping ReadByte for Read for the message body (based on Content-Length) or chunked message body byte retrieval into an appropriately sized buffer, using ReadByte in all other areas (such as reading the Headers, Chunk sizes etc).
I'm interested to know thoughts on better / different ways to do this to achieve optimum performance? Obviously the main problem with HTTP is not knowing the length of the response stream unless it is parsed as it is retrieved.
There a specific reasons why I'm not using more abstract classes (eg HttpWebRequest) for this (I need better control at the socket level).
Many Thanks,
Chris