mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +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:
parent
05d28bc045
commit
8f6e0dd339
@ -677,9 +677,20 @@ 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;
|
||||||
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
|
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);
|
||||||
|
} else if (written == 0) {
|
||||||
|
return returnError(HTTPC_ERROR_CONNECTION_LOST);
|
||||||
|
}
|
||||||
|
byteswritten += written;
|
||||||
|
size -= written;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user