Getting response of http request without content-length?

See relevant part of HTTP spec. In your specific case, if the server does not give content length back, then it MUST be closing the stream upon finishing the response. There is no other reliable way for you (as a client) to know. Regardless of HTTP version. @Julian chunked encoding is indeed a clever upgrade in HTTP/1.1 but is rather specific to streaming and there is no reason why a "plain" webserver would implement it. That is a server which knows the content length before initiating response. And i guess that the OP doesn't have the server under control, otherwise he won't be objecting missing HTTP headers.

But even if you DO get the content length header, you must not unreservedly trust it. The server implementors are only fallible humans too. Take it as a "most probable" response, initial value to a resizable buffer. You still must be ready to handle less as well as more (the worse case).


In HTTP/1.0 - server response without content-length is when the stream closes

In HTTP/1.1 - server response without content-length is when the response is chunked encoded