Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
dd649808
Commit
dd649808
authored
Apr 10, 2019
by
boarchuz
Committed by
Me No Dev
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add server connect timeout to HTTPClient (#2606)
parent
67ee7c32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
libraries/HTTPClient/src/HTTPClient.cpp
libraries/HTTPClient/src/HTTPClient.cpp
+11
-2
libraries/HTTPClient/src/HTTPClient.h
libraries/HTTPClient/src/HTTPClient.h
+2
-0
No files found.
libraries/HTTPClient/src/HTTPClient.cpp
View file @
dd649808
...
...
@@ -428,6 +428,15 @@ void HTTPClient::setAuthorization(const char * auth)
}
}
/**
* set the timeout (ms) for establishing a connection to the server
* @param connectTimeout int32_t
*/
void
HTTPClient
::
setConnectTimeout
(
int32_t
connectTimeout
)
{
_connectTimeout
=
connectTimeout
;
}
/**
* set the timeout for the TCP connection
* @param timeout unsigned int
...
...
@@ -442,7 +451,7 @@ void HTTPClient::setTimeout(uint16_t timeout)
/**
* use HTTP1.0
* @param
timeout
* @param
use
*/
void
HTTPClient
::
useHTTP10
(
bool
useHTTP10
)
{
...
...
@@ -966,7 +975,7 @@ bool HTTPClient::connect(void)
return
false
;
}
if
(
!
_client
->
connect
(
_host
.
c_str
(),
_port
))
{
if
(
!
_client
->
connect
(
_host
.
c_str
(),
_port
,
_connectTimeout
))
{
log_d
(
"failed connect to %s:%u"
,
_host
.
c_str
(),
_port
);
return
false
;
}
...
...
libraries/HTTPClient/src/HTTPClient.h
View file @
dd649808
...
...
@@ -153,6 +153,7 @@ public:
void
setUserAgent
(
const
String
&
userAgent
);
void
setAuthorization
(
const
char
*
user
,
const
char
*
password
);
void
setAuthorization
(
const
char
*
auth
);
void
setConnectTimeout
(
int32_t
connectTimeout
);
void
setTimeout
(
uint16_t
timeout
);
void
useHTTP10
(
bool
usehttp10
=
true
);
...
...
@@ -213,6 +214,7 @@ protected:
/// request handling
String
_host
;
uint16_t
_port
=
0
;
int32_t
_connectTimeout
=
-
1
;
bool
_reuse
=
false
;
uint16_t
_tcpTimeout
=
HTTPCLIENT_DEFAULT_TCP_TIMEOUT
;
bool
_useHTTP10
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment