1
0
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:
George Talusan
2015-12-22 21:31:30 -05:00
parent ee2d4495fd
commit 70c85c0901
2 changed files with 16 additions and 10 deletions

View File

@ -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;