File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 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)
428428 }
429429}
430430
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+
431440/* *
432441 * set the timeout for the TCP connection
433442 * @param timeout unsigned int
@@ -442,7 +451,7 @@ void HTTPClient::setTimeout(uint16_t timeout)
442451
443452/* *
444453 * use HTTP1.0
445- * @param timeout
454+ * @param use
446455 */
447456void HTTPClient::useHTTP10 (bool useHTTP10)
448457{
@@ -966,7 +975,7 @@ bool HTTPClient::connect(void)
966975 return false ;
967976 }
968977
969- if (!_client->connect (_host.c_str (), _port)) {
978+ if (!_client->connect (_host.c_str (), _port, _connectTimeout )) {
970979 log_d (" failed connect to %s:%u" , _host.c_str (), _port);
971980 return false ;
972981 }
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ class HTTPClient
153153 void setUserAgent (const String& userAgent);
154154 void setAuthorization (const char * user, const char * password);
155155 void setAuthorization (const char * auth);
156+ void setConnectTimeout (int32_t connectTimeout);
156157 void setTimeout (uint16_t timeout);
157158
158159 void useHTTP10 (bool usehttp10 = true );
@@ -213,6 +214,7 @@ class HTTPClient
213214 // / request handling
214215 String _host;
215216 uint16_t _port = 0 ;
217+ int32_t _connectTimeout = -1 ;
216218 bool _reuse = false ;
217219 uint16_t _tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
218220 bool _useHTTP10 = false ;
You can’t perform that action at this time.
0 commit comments