tcp - Getting response of http request without content-length? -
i have little program sends http request , gets response tcp protocol.
my request format;
get / http/1.0 host: somewebsite.com {two new line}
i read response line line socket (using networkstream , streamreader in c#) until find content-length header. store length, continue reading until find empty line. create buffer length , receive rest of response.
but reponses not have content-length header. approach fails. if don't know how many bytes should receive, when should stop?
in http/1.0? when stream closes.
in http/1.1? chunked encoding.
Comments
Post a Comment