Skip to content

Commit 058ce7c

Browse files
authored
Allow control over HTTPClient authorization String allocation (#8225)
1 parent 65db3ae commit 058ce7c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,26 @@ void HTTPClient::setAuthorization(const char * user, const char * password)
276276
}
277277

278278
/**
279-
* set the Authorizatio for the http request
279+
* set the Authorization for the http request
280280
* @param auth const char * base64
281281
*/
282282
void HTTPClient::setAuthorization(const char * auth)
283283
{
284-
if(auth) {
285-
_base64Authorization = auth;
286-
_base64Authorization.replace(String('\n'), emptyString);
284+
if (auth) {
285+
setAuthorization(String(auth));
287286
}
288287
}
289288

289+
/**
290+
* set the Authorization for the http request
291+
* @param auth String base64
292+
*/
293+
void HTTPClient::setAuthorization(String auth)
294+
{
295+
_base64Authorization = std::move(auth);
296+
_base64Authorization.replace(String('\n'), emptyString);
297+
}
298+
290299
/**
291300
* set the timeout for the TCP connection
292301
* @param timeout unsigned int

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class HTTPClient
176176
void setUserAgent(const String& userAgent);
177177
void setAuthorization(const char * user, const char * password);
178178
void setAuthorization(const char * auth);
179+
void setAuthorization(String auth);
179180
void setTimeout(uint16_t timeout);
180181

181182
// Redirections

0 commit comments

Comments
 (0)