File tree 2 files changed +16
-3
lines changed
libraries/ESP8266HTTPClient/src
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ HTTPClient::HTTPClient() {
50
50
_returnCode = 0 ;
51
51
_size = -1 ;
52
52
_canReuse = false ;
53
+ _tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
53
54
54
55
}
55
56
@@ -252,6 +253,17 @@ void HTTPClient::setAuthorization(const char * auth) {
252
253
}
253
254
}
254
255
256
+ /* *
257
+ * set the timeout for the TCP connection
258
+ * @param timeout unsigned int
259
+ */
260
+ void HTTPClient::setTimeout (uint16_t timeout) {
261
+ _tcpTimeout = timeout;
262
+ if (connected ()) {
263
+ _tcp->setTimeout (timeout);
264
+ }
265
+ }
266
+
255
267
/* *
256
268
* send a GET request
257
269
* @return http code
@@ -673,7 +685,7 @@ bool HTTPClient::connect(void) {
673
685
}
674
686
675
687
// set Timeout for readBytesUntil and readStringUntil
676
- _tcp->setTimeout (HTTPCLIENT_TCP_TIMEOUT );
688
+ _tcp->setTimeout (_tcpTimeout );
677
689
678
690
#ifdef ESP8266
679
691
_tcp->setNoDelay (true );
Original file line number Diff line number Diff line change 31
31
#define DEBUG_HTTPCLIENT (...)
32
32
#endif
33
33
34
- #define HTTPCLIENT_TCP_TIMEOUT (1000 )
34
+ #define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (1000 )
35
35
36
36
// / HTTP client errors
37
37
#define HTTPC_ERROR_CONNECTION_REFUSED (-1 )
@@ -127,6 +127,7 @@ class HTTPClient {
127
127
void setUserAgent (const char * userAgent);
128
128
void setAuthorization (const char * user, const char * password);
129
129
void setAuthorization (const char * auth);
130
+ void setTimeout (uint16_t timeout);
130
131
131
132
// / request handling
132
133
int GET ();
@@ -170,7 +171,7 @@ class HTTPClient {
170
171
String _host;
171
172
uint16_t _port;
172
173
bool _reuse;
173
-
174
+ uint16_t _tcpTimeout;
174
175
175
176
String _url;
176
177
bool _https;
You can’t perform that action at this time.
0 commit comments