Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7aa1913

Browse filesBrowse files
committed
Allow HTTPS without certificate to use begin(url)
1 parent 4230aec commit 7aa1913
Copy full SHA for 7aa1913

File tree

Expand file treeCollapse file tree

1 file changed

+9
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-4
lines changed

‎libraries/HTTPClient/src/HTTPClient.cpp

Copy file name to clipboardExpand all lines: libraries/HTTPClient/src/HTTPClient.cpp
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ bool HTTPClient::begin(String url, const char* CAcert)
120120
*/
121121
bool HTTPClient::begin(String url)
122122
{
123+
124+
if (beginInternal(url, "https")) {
125+
return begin(url, (const char*)NULL);
126+
}
123127
_transportTraits.reset(nullptr);
124128
_port = 80;
125129
if (!beginInternal(url, "http")) {
@@ -143,6 +147,11 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
143147
}
144148

145149
_protocol = url.substring(0, index);
150+
if (_protocol != expectedProtocol) {
151+
log_d("[HTTP-Client][begin] unexpected protocol: %s, expected %s", _protocol.c_str(), expectedProtocol);
152+
return false;
153+
}
154+
146155
url.remove(0, (index + 3)); // remove http:// or https://
147156

148157
index = url.indexOf('/');
@@ -168,10 +177,6 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
168177
_host = host;
169178
}
170179
_uri = url;
171-
if (_protocol != expectedProtocol) {
172-
log_d("[HTTP-Client][begin] unexpected protocol: %s, expected %s", _protocol.c_str(), expectedProtocol);
173-
return false;
174-
}
175180
log_d("[HTTP-Client][begin] host: %s port: %d url: %s", _host.c_str(), _port, _uri.c_str());
176181
return true;
177182
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.