I noticed when making a http request using an ESP8266 wifi module attached to a Serial1 of Leonardo (Atmel32u4) board the final response "SEND OK" from the module to confirm data has been sent comes with a human noticeable delay.
When the ESP8266 on Serial1 has got the data to send it confirms by
Recv 83 bytes SEND OK
The strange thing is there is a 290ms delay between "Recv 83 bytes" and "SEND OK"
It can only be noticed if the response from the HTTP request is delayed. For http requests with short response time, like 10ms, the "Recv 83 bytes" comes immediately after the TXO to the ESP device has completed. The "SEND OK" comes in front of the HTTP header following 10ms later.
So if there is no data back in the web request within 290ms you have to wait that long to have a confirmation the send was completed.
When there is no immediate response on the input stream "SEND OK" is 290ms delayed?
When http response is fast the "SEND OK" is before the HTTP response.
I have checked to be sure "SEND OK" is not following "Recv 83 bytes" the length of "Recv 83 bytes" is 1.52ms so it is not hiding there. It comes with the HTTP response.
I did not want to involve the Arduino code or timing in Serial1. The pictures show what is going on on the Serial1 interface between Arduino and the ESP8266.
Since this device is used in milions I must be close to false.
I have control of the web server and can delay http responses with ms resolution and I can clearly see "Recv NN bytes" and "SEND OK" be appart.
This becomes a problem when looping the send to stream data in smaller blocks. I think I have to wait for the "SEND OK" or can I move on and SEND again as soon as the "Recv NN bytes" is confirmed.