Add support for large uploads to HTTPClient (#8006)

This commit is contained in:
Me No Dev 2023-03-31 13:39:38 +03:00 committed by GitHub
parent 82de3429cb
commit bad5af9e1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -619,7 +619,21 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size)
// send Payload if needed
if(payload && size > 0) {
if(_client->write(&payload[0], size) != size) {
size_t sent_bytes = 0;
while(sent_bytes < size){
size_t sent = _client->write(&payload[sent_bytes], size - sent_bytes);
if (sent == 0){
log_w("Failed to send chunk! Lets wait a bit");
delay(100);
sent = _client->write(&payload[sent_bytes], size - sent_bytes);
if (sent == 0){
log_e("Failed to send chunk!");
break;
}
}
sent_bytes += sent;
}
if(sent_bytes != size){
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
}
}