You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Message bigger than 1460 bytes can't be send.
ESP8266HTTPClient.CPP
Problem is in:
Function: int HTTPClient::sendRequest(const char * type, const uint8_t * payload, size_t size)
// send Payload if needed
if (payload && size > 0) {
size_t bytesWritten = 0;
const uint8_t *p = payload;
while (bytesWritten < size) {
int written;
int towrite = std::min((int)size, (int)HTTP_TCP_BUFFER_SIZE);
written = _client->write(p + bytesWritten, towrite);
if (written < 0) {
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
} else if (written == 0) {
return returnError(HTTPC_ERROR_CONNECTION_LOST);
}
bytesWritten += written;
size -= written;
}
}
Problematic is: size -= written; - because SIZE is subtracting every loop and then in WHILE is compared to overal bytes sent. Only first chunk 1460 bytes can be send.
Solution: size -= written; - this should be erased. bytesWritten += written; - this is enough for this function.
Proper code is:
// send Payload if needed
if (payload && size > 0) {
size_t bytesWritten = 0;
const uint8_t *p = payload;
while (bytesWritten < size) {
int written;
int towrite = std::min((int)size, (int)HTTP_TCP_BUFFER_SIZE);
written = _client->write(p + bytesWritten, towrite);
if (written < 0) {
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
} else if (written == 0) {
return returnError(HTTPC_ERROR_CONNECTION_LOST);
}
bytesWritten += written;
//size -= written;
}
}
The text was updated successfully, but these errors were encountered:
Someone (a maintainer or any other volunteer) will address this issue very soon.
Please leave it opened, it will be closed when fixed.
This is not a github process but a git process, if you are familiar with the git tool.
Message bigger than 1460 bytes can't be send.
ESP8266HTTPClient.CPP
Problem is in:
Problematic is:
size -= written;
- because SIZE is subtracting every loop and then in WHILE is compared to overal bytes sent. Only first chunk 1460 bytes can be send.Solution:
size -= written;
- this should be erased.bytesWritten += written;
- this is enough for this function.Proper code is:
The text was updated successfully, but these errors were encountered: