-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Update HTTPClient.cpp to send big payload #7638
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -604,6 +604,9 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size) | |
|
|
||
| if(payload && size > 0) { | ||
| addHeader(F("Content-Length"), String(size)); | ||
| } else { | ||
| // force 0 content length for redirect request | ||
| addHeader(F("Content-Length"), String("0")); | ||
| } | ||
|
|
||
| // add cookies to header, if present | ||
|
|
@@ -619,10 +622,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) { | ||
| return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED); | ||
|
|
||
| // this will fail for big payload | ||
| // if(_client->write(&payload[0], size) != size) { | ||
| // return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED); | ||
| // } | ||
|
|
||
| // send the payload per 1000 bytes | ||
| log_d("Sending %u byte ...\n", size); | ||
|
||
| size_t sent_bytes = 0; | ||
| for (size_t id_data = 0; id_data < size; id_data+=1000) | ||
|
||
| { | ||
| sent_bytes = _client->write(&payload[id_data], ((id_data+1000)<=size)?1000:(size-id_data)); | ||
| log_d("Sent %u bytes\n", sent_bytes); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| code = handleHeaderResponse(); | ||
| log_d("sendRequest code=%d\n", code); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of leaving the old code in comments, it would be better to simply drop it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atanisoft Fixed. Please kindly check it. Thank you.