Reading http class stream fails to receive data

I am trying to receive POST response from externaly hosted PHP file.
I was Following the StreamHttpClient example which came with mine IDE and came-up with

void loop() {
 // wait for WiFi connection
 // if (( == WL_CONNECTED)) {
   if(!digitalRead(obnovaTlacitko)) {
       WiFiClient client;
       HTTPClient http; //must be declared after WiFiClient for correct destruction order, because used by http.begin(client,...)
       http.begin("Full website adress");
       http.addHeader("Content-Type", "application/x-www-form-urlencoded");
       String httpRequestData = "Mine Post variables";
       int httpResponseCode = http.POST(httpRequestData);

       // get lenght of document (is -1 when Server sends no Content-Length header)
       int len = http.getSize();
       Serial.printf(F("Dostávam odpoveď dĺžky %d\n"),len);
       char buff[128]={'/0'};
       // read all data from server
       // get tcp stream
       WiFiClient * stream = &client;

       // read all data from server
       while (http.connected() && (len > 0 || len == -1)) {
         // read up to 128 byte
         int c = stream->readBytes(buff, std::min((size_t)len, sizeof(buff)));
         Serial.printf("readBytes: %d\n", c);
         if (!c) {
           Serial.println("read timeout");

         // write it to Serial
         Serial.write(buff, c);

         if (len > 0) {
           len -= c;

       Serial.print("[HTTP] connection closed or file end.\n");
   }/* else {
     Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(cisloOdpovede).c_str());

if I use </>Serial.println(http.getString());</> Everything works, but when I try to read data from stream I get time-out and no data is read. I have tried to use read(), but that resulted in infinite while loop as the data was newer emptied and client staid connected…

I am using ESP8266 but for final device I am considering its realtek alternative (I have more trust towards realtek when it comes to long-term reliability and opensource support, over the company whose product become major player because some Russian bloke noticed its cheap. I am using IDE only for compilation…

Hi and welcome to the Forum! Can you please post code in code tags ( </> ) ( the button is found in the toolbar of reply )! Also please read how to get the best out of the forum! And you have posted in the Installation and Troubleshooting board while, this topic should go under the Programming questions board…!

Fixed the coding.
I have been mod on few forums and did not realized that I cant use </> as a markup(No markup on a programing forum), but it is only a symbol for code, so I have had code between two </>
I am not sure how the wrong assignment happen, I was in believe that I am putting it into communication. Unfortunately I do not see the option of shifting this thema so I would ask any mod passing if they can do it or you to advise me where to find the option

Thread moved as requested.

Tomas, you didn’t pass the client object into http object. http then uses internal client object.
the example has
http.begin(client, “Connection Header”);

the example has some recent changes and the WiFiClient * stream = &client; doesn’t make much sense now.
simply use the client object to read the data.