mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
handle short writes
This commit is contained in:
@ -363,7 +363,12 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size) {
|
||||
int c = stream->readBytes(buff, ((s > buff_size) ? buff_size : s));
|
||||
|
||||
// write it to Stream
|
||||
bytesWritten += _tcp->write((const uint8_t *) buff, c);
|
||||
int w = _tcp->write((const uint8_t *) buff, c);
|
||||
if(w != c) {
|
||||
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] short write asked for %d but got %d\n", c, w);
|
||||
break;
|
||||
}
|
||||
bytesWritten += c;
|
||||
|
||||
if(len > 0) {
|
||||
len -= c;
|
||||
@ -470,7 +475,12 @@ int HTTPClient::writeToStream(Stream * stream) {
|
||||
int c = _tcp->readBytes(buff, ((size > buff_size) ? buff_size : size));
|
||||
|
||||
// write it to Stream
|
||||
bytesWritten += stream->write(buff, c);
|
||||
int w = stream->write(buff, c);
|
||||
if(w != c) {
|
||||
DEBUG_HTTPCLIENT("[HTTP-Client][writeToStream] short write asked for %d but got %d\n", c, w);
|
||||
break;
|
||||
}
|
||||
bytesWritten += c;
|
||||
|
||||
if(len > 0) {
|
||||
len -= c;
|
||||
|
Reference in New Issue
Block a user