Skip to content

Add support for large uploads to HTTPClient #8006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion libraries/HTTPClient/src/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down