mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-26 07:02:15 +03:00
Stream::send() (#6979)
This commit is contained in:
@ -37,22 +37,8 @@ namespace esp8266webserver {
|
||||
template <typename ServerType>
|
||||
static bool readBytesWithTimeout(typename ServerType::ClientType& client, size_t maxLength, String& data, int timeout_ms)
|
||||
{
|
||||
if (!data.reserve(maxLength + 1))
|
||||
return false;
|
||||
data[0] = 0; // data.clear()??
|
||||
while (data.length() < maxLength) {
|
||||
int tries = timeout_ms;
|
||||
size_t avail;
|
||||
while (!(avail = client.available()) && tries--)
|
||||
delay(1);
|
||||
if (!avail)
|
||||
break;
|
||||
if (data.length() + avail > maxLength)
|
||||
avail = maxLength - data.length();
|
||||
while (avail--)
|
||||
data += (char)client.read();
|
||||
}
|
||||
return data.length() == maxLength;
|
||||
S2Stream dataStream(data);
|
||||
return client.sendSize(dataStream, maxLength, timeout_ms) == maxLength;
|
||||
}
|
||||
|
||||
template <typename ServerType>
|
||||
|
Reference in New Issue
Block a user