Add support for large uploads to HTTPClient (#8006)
This commit is contained in:
parent
82de3429cb
commit
bad5af9e1c
1 changed files with 15 additions and 1 deletions
|
|
@ -619,7 +619,21 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size)
|
||||||
|
|
||||||
// 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 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);
|
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue