1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

Allow for POSTs larger than a few 100 bytes (#6800)

This is all @dirkx , whose PR unfortunately got borked when we were
trying to update it to the new format.  As @dirkx said:

When sending POST responses of well over a K - _write() may not sent it
all. Make sure we do -- but cap the individual writes - as somehow large
2-3k blobs seem to cause instability (on my 12F units).

Supercedes #2528
This commit is contained in:
Earle F. Philhower, III 2019-11-23 21:53:29 -07:00 committed by Develo
parent 05d28bc045
commit 8f6e0dd339

View File

@ -678,8 +678,19 @@ int HTTPClient::sendRequest(const char * type, const uint8_t * payload, size_t s
// send Payload if needed // send Payload if needed
if (payload && size > 0) { if (payload && size > 0) {
if(_client->write(&payload[0], size) != size) { size_t byteswritten = 0;
const uint8_t *p = payload;
while (byteswritten < size) {
int written;
int towrite = std::min((int)size, (int)HTTP_TCP_BUFFER_SIZE);
written = _client->write(p, towrite);
if (written < 0) {
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED); return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
} else if (written == 0) {
return returnError(HTTPC_ERROR_CONNECTION_LOST);
}
byteswritten += written;
size -= written;
} }
} }