HTTP client similar to cURL
Since it looks like you don't wait for a specific length of data I assume that you have no idea how to get the length of the data up-front. Since you are willing to learn how HTTP/1.x works I recommend you to read the specifications and watch out for something like "Content-length" and "Transfer-Encoding: chunked". Once you've understood why these are important and how to correctly deal with them you can write your code so that it does not timeout.