8000 fixes for WiFiClient::write(Stream) by d-a-v · Pull Request #7987 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

fixes for WiFiClient::write(Stream) #7987

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

Merged
merged 8 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
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
Next Next commit
fixes for WiFiClient::write(Stream)
- remove deprecated WiFiClient::write(Stream,size)
- fix and deprecate WiFiClient::write(Stream) to use Stream::sendAll instead of ::sendAvailable
- update ESP8266WebServer::streamFile to use file.sendAll(client) instead of client.write(file)
  • Loading branch information
d-a-v committed Apr 15, 2021
commit ae879789a7ad6c388c8bdf02c6b833fdd5658803
2 changes: 1 addition & 1 deletion libraries/ESP8266WebServer/src/ESP8266WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class ESP8266WebServerTemplate
size_t contentLength = 0;
_streamFileCore(file.size(), file.name(), contentType);
if (requestMethod == HTTP_GET) {
contentLength = _currentClient.write(file);
contentLength = file.sendAll(_currentClient);
}
return contentLength;
}
Expand Down
16 changes: 4 additions & 12 deletions libraries/ESP8266WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,16 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
return _client->write(ptr);
}

size_t WiFiClient::write(Stream& stream, size_t unused)
{
(void) unused;
return WiFiClient::write(stream);
}

size_t WiFiClient::write(Stream& stream)
{
// (this method is deprecated)

if (!_client || !stream.available())
{
return 0;
}
if (stream.hasPeekBufferAPI())
{
_client->setTimeout(_timeout);
return _client->write(stream);
}
return stream.sendAvailable(this);
// core up to 2.7.4 was equivalent to this from within ClientContext
return stream.sendAll(this);
}

size_t WiFiClient::write_P(PGM_P buf, size_t size)
Expand Down
5 changes: 1 addition & 4 deletions libraries/ESP8266WiFi/src/WiFiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ class WiFiClient : public Client, public SList<WiFiClient> {
virtual size_t write(uint8_t) override;
virtual size_t write(const uint8_t *buf, size_t size) override;
virtual size_t write_P(PGM_P buf, size_t size);
size_t write(Stream& stream);

// This one is deprecated, use write(Stream& instead)
size_t write(Stream& stream, size_t unitSize) __attribute__ ((deprecated));
size_t write(Stream& stream) [[ deprecated("use stream.sendHow(client...)") ]];

virtual int available() override;
virtual int read() override;
Expand Down
0