mirror of
https://github.com/arduino-libraries/ArduinoHttpClient.git
synced 2025-04-19 21:22:15 +03:00
Reworked HttpClient::read() so it doesn't hit the bug in WiFiClient::read(...) (the mulit-byte version)
This commit is contained in:
parent
8bca4a37d2
commit
ea1618be0e
@ -309,6 +309,8 @@ int HttpClient::responseStatusCode()
|
|||||||
if (available())
|
if (available())
|
||||||
{
|
{
|
||||||
c = read();
|
c = read();
|
||||||
|
if (c != -1)
|
||||||
|
{
|
||||||
switch(iState)
|
switch(iState)
|
||||||
{
|
{
|
||||||
case eRequestSent:
|
case eRequestSent:
|
||||||
@ -350,6 +352,7 @@ int HttpClient::responseStatusCode()
|
|||||||
// We read something, reset the timeout counter
|
// We read something, reset the timeout counter
|
||||||
timeoutStart = millis();
|
timeoutStart = millis();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We haven't got any data, so let's pause to allow some to
|
// We haven't got any data, so let's pause to allow some to
|
||||||
@ -430,6 +433,7 @@ bool HttpClient::endOfBodyReached()
|
|||||||
|
|
||||||
int HttpClient::read()
|
int HttpClient::read()
|
||||||
{
|
{
|
||||||
|
#if 0 // Fails on WiFi because multi-byte read seems to be broken
|
||||||
uint8_t b[1];
|
uint8_t b[1];
|
||||||
int ret = read(b, 1);
|
int ret = read(b, 1);
|
||||||
if (ret == 1)
|
if (ret == 1)
|
||||||
@ -440,6 +444,19 @@ int HttpClient::read()
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int ret = iClient->read();
|
||||||
|
if (ret >= 0)
|
||||||
|
{
|
||||||
|
if (endOfHeadersReached() && iContentLength > 0)
|
||||||
|
{
|
||||||
|
// We're outputting the body now and we've seen a Content-Length header
|
||||||
|
// So keep track of how many bytes are left
|
||||||
|
iBodyLengthConsumed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int HttpClient::read(uint8_t *buf, size_t size)
|
int HttpClient::read(uint8_t *buf, size_t size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user