Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bad5af9

Browse filesBrowse files
authored
Add support for large uploads to HTTPClient (espressif#8006)
1 parent 82de342 commit bad5af9
Copy full SHA for bad5af9

File tree

Expand file treeCollapse file tree

1 file changed

+15
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-1
lines changed

‎libraries/HTTPClient/src/HTTPClient.cpp

Copy file name to clipboardExpand all lines: libraries/HTTPClient/src/HTTPClient.cpp
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,21 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size)
619619

620620
// send Payload if needed
621621
if(payload && size > 0) {
622-
if(_client->write(&payload[0], size) != size) {
622+
size_t sent_bytes = 0;
623+
while(sent_bytes < size){
624+
size_t sent = _client->write(&payload[sent_bytes], size - sent_bytes);
625+
if (sent == 0){
626+
log_w("Failed to send chunk! Lets wait a bit");
627+
delay(100);
628+
sent = _client->write(&payload[sent_bytes], size - sent_bytes);
629+
if (sent == 0){
630+
log_e("Failed to send chunk!");
631+
break;
632+
}
633+
}
634+
sent_bytes += sent;
635+
}
636+
if(sent_bytes != size){
623637
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
624638
}
625639
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.