TCP Client not reading anything

That’s great guys, thanks a lot for the fast feedback and workarounds, in my case I was able to fix the code looping until available() returned something:

String http_get(char const* hostname, String path) {

    if (client.connect(hostname, 80)) {
            client.print("GET ");
            client.print(path);
            client.print(" HTTP/1.0\r\n");
            client.print("HOST: ");
            client.println(hostname);
            client.println();
            client.flush();
    } else {
            Serial.println("connection failed");
            client.stop();
            return NULL;
    }

    int bytes = 0;
    while(!bytes && client.connected()) {
	    bytes = client.available();
	    delay(200);
    }
	Serial.println("bytes:");
	Serial.println(bytes);

	for (unsigned int i = 0;  i  < bytes; i++) {
		char c = client.read();
			Serial.print(c);
		if (c == -1) {
		    	Serial.println("oops");
			break;
		}

		buffer[i] = c;
	
	}
	client.stop();

    String response(buffer);
    int bodyPos = response.indexOf("\r\n\r\n");
    if (bodyPos == -1) {
            Serial.println("can not find http get reponse body");
                            return NULL;
    }
    return response.substring(bodyPos+4);

}

B​Dub’s code seems more elegant as it doesn’t use delay that much and as he mentioned connected() always returns true which makes mine redundant. I’ll change to that if in the following weeks we don’t get the fixed merged into compile-server2.