mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Allow setting TCP timeout
This commit is contained in:
parent
7a010a38cc
commit
d1a6b32133
@ -50,6 +50,7 @@ HTTPClient::HTTPClient() {
|
|||||||
_returnCode = 0;
|
_returnCode = 0;
|
||||||
_size = -1;
|
_size = -1;
|
||||||
_canReuse = false;
|
_canReuse = false;
|
||||||
|
_tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +253,14 @@ void HTTPClient::setAuthorization(const char * auth) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the timeout for the TCP connection
|
||||||
|
* @param timeout unsigned int
|
||||||
|
*/
|
||||||
|
void HTTPClient::setTimeout(uint16_t timeout) {
|
||||||
|
_tcpTimeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send a GET request
|
* send a GET request
|
||||||
* @return http code
|
* @return http code
|
||||||
@ -673,7 +682,7 @@ bool HTTPClient::connect(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set Timeout for readBytesUntil and readStringUntil
|
// set Timeout for readBytesUntil and readStringUntil
|
||||||
_tcp->setTimeout(HTTPCLIENT_TCP_TIMEOUT);
|
_tcp->setTimeout(_tcpTimeout);
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
_tcp->setNoDelay(true);
|
_tcp->setNoDelay(true);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#define DEBUG_HTTPCLIENT(...)
|
#define DEBUG_HTTPCLIENT(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HTTPCLIENT_TCP_TIMEOUT (1000)
|
#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (1000)
|
||||||
|
|
||||||
/// HTTP client errors
|
/// HTTP client errors
|
||||||
#define HTTPC_ERROR_CONNECTION_REFUSED (-1)
|
#define HTTPC_ERROR_CONNECTION_REFUSED (-1)
|
||||||
@ -127,6 +127,7 @@ class HTTPClient {
|
|||||||
void setUserAgent(const char * userAgent);
|
void setUserAgent(const char * userAgent);
|
||||||
void setAuthorization(const char * user, const char * password);
|
void setAuthorization(const char * user, const char * password);
|
||||||
void setAuthorization(const char * auth);
|
void setAuthorization(const char * auth);
|
||||||
|
void setTimeout(uint16_t timeout);
|
||||||
|
|
||||||
/// request handling
|
/// request handling
|
||||||
int GET();
|
int GET();
|
||||||
@ -170,7 +171,7 @@ class HTTPClient {
|
|||||||
String _host;
|
String _host;
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
bool _reuse;
|
bool _reuse;
|
||||||
|
uint16_t _tcpTimeout;
|
||||||
|
|
||||||
String _url;
|
String _url;
|
||||||
bool _https;
|
bool _https;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user