File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -428,6 +428,15 @@ void HTTPClient::setAuthorization(const char * auth)
428
428
}
429
429
}
430
430
431
+ /* *
432
+ * set the timeout (ms) for establishing a connection to the server
433
+ * @param connectTimeout int32_t
434
+ */
435
+ void HTTPClient::setConnectTimeout (int32_t connectTimeout)
436
+ {
437
+ _connectTimeout = connectTimeout;
438
+ }
439
+
431
440
/* *
432
441
* set the timeout for the TCP connection
433
442
* @param timeout unsigned int
@@ -442,7 +451,7 @@ void HTTPClient::setTimeout(uint16_t timeout)
442
451
443
452
/* *
444
453
* use HTTP1.0
445
- * @param timeout
454
+ * @param use
446
455
*/
447
456
void HTTPClient::useHTTP10 (bool useHTTP10)
448
457
{
@@ -966,7 +975,7 @@ bool HTTPClient::connect(void)
966
975
return false ;
967
976
}
968
977
969
- if (!_client->connect (_host.c_str (), _port)) {
978
+ if (!_client->connect (_host.c_str (), _port, _connectTimeout )) {
970
979
log_d (" failed connect to %s:%u" , _host.c_str (), _port);
971
980
return false ;
972
981
}
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ class HTTPClient
153
153
void setUserAgent (const String& userAgent);
154
154
void setAuthorization (const char * user, const char * password);
155
155
void setAuthorization (const char * auth);
156
+ void setConnectTimeout (int32_t connectTimeout);
156
157
void setTimeout (uint16_t timeout);
157
158
158
159
void useHTTP10 (bool usehttp10 = true );
@@ -213,6 +214,7 @@ class HTTPClient
213
214
// / request handling
214
215
String _host;
215
216
uint16_t _port = 0 ;
217
+ int32_t _connectTimeout = -1 ;
216
218
bool _reuse = false ;
217
219
uint16_t _tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
218
220
bool _useHTTP10 = false ;
You can’t perform that action at this time.
0 commit comments