It is basically working but the code I have got now is pretty crummy and does occasionally not get the full HTTP message containing a big JSON string.
The examples I found online just assume the Server replies with a short response packet so it simplifies things. My real world larger response has to loop waiting for more packets to come in. Pseudo code is below
- while ((size = client.available()) > 0)
- {
- size = client.read(&msgBig[bufPtr], size);
- bufPtr += size;
- int retries = 0;
- while (client.available() == 0 && retries++ < 20)
- {
- delay(2);
- }
- }
There must be a better way of doing this, can someone with a better knowledge of HTTP protocol and ESP32 libraries comment please ?
Thanks Geoff