Skip to content

Allow for POSTs that are larger than a few 100 bytes. #2528

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
19 changes: 17 additions & 2 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,23 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size)

// send Payload if needed
if(payload && size > 0) {
if(_tcp->write(&payload[0], size) != size) {
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
size_t byteswritten = 0;
uint8_t * p = payload;
while(byteswritten < size) {
int written;
int towrite = size;
// Note: this cap may be on the small size; but over about 2k will cause coredumps.
//
if (towrite > HTTP_TCP_BUFFER_SIZE)
towrite = HTTP_TCP_BUFFER_SIZE;
written = _tcp->write(&p[0], towrite);
if (written < 0)
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
else
if (written == 0)
return returnError(HTTPC_ERROR_CONNECTION_LOST);
byteswritten += size;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 406 is incorrect. It should be:

byteswritten += written;

Chuck

size -= written;
}
}

Expand Down