1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-27 21:16:50 +03:00

improve handling of non http servers

This commit is contained in:
Markus Sattler 2015-11-22 15:58:15 +01:00
parent be91d96774
commit 6ed7dfe537
2 changed files with 10 additions and 1 deletions

View File

@ -386,6 +386,9 @@ int httpClient::handleHeaderResponse() {
return HTTPC_ERROR_NOT_CONNECTED; return HTTPC_ERROR_NOT_CONNECTED;
} }
_returnCode = -1;
_size = -1;
while(connected()) { while(connected()) {
size_t len = _tcp->available(); size_t len = _tcp->available();
if(len > 0) { if(len > 0) {
@ -421,7 +424,12 @@ int httpClient::handleHeaderResponse() {
if(_size) { if(_size) {
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] size: %d\n", _size); DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] size: %d\n", _size);
} }
return _returnCode; if(_returnCode) {
return _returnCode;
} else {
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Remote host is not an HTTP Server!");
return HTTPC_ERROR_NO_HTTP_SERVER;
}
} }
} else { } else {

View File

@ -40,6 +40,7 @@
#define HTTPC_ERROR_NOT_CONNECTED (-4) #define HTTPC_ERROR_NOT_CONNECTED (-4)
#define HTTPC_ERROR_CONNECTION_LOST (-5) #define HTTPC_ERROR_CONNECTION_LOST (-5)
#define HTTPC_ERROR_NO_STREAM (-6) #define HTTPC_ERROR_NO_STREAM (-6)
#define HTTPC_ERROR_NO_HTTP_SERVER (-7)
class httpClient { class httpClient {