Skip to content

Commit

Permalink
Allow control over HTTPClient authorization String allocation (#8225)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulocsanz committed Sep 4, 2021
1 parent 65db3ae commit 058ce7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,26 @@ void HTTPClient::setAuthorization(const char * user, const char * password)
}

/**
* set the Authorizatio for the http request
* set the Authorization for the http request
* @param auth const char * base64
*/
void HTTPClient::setAuthorization(const char * auth)
{
if(auth) {
_base64Authorization = auth;
_base64Authorization.replace(String('\n'), emptyString);
if (auth) {
setAuthorization(String(auth));
}
}

/**
* set the Authorization for the http request
* @param auth String base64
*/
void HTTPClient::setAuthorization(String auth)
{
_base64Authorization = std::move(auth);
_base64Authorization.replace(String('\n'), emptyString);
}

/**
* set the timeout for the TCP connection
* @param timeout unsigned int
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class HTTPClient
void setUserAgent(const String& userAgent);
void setAuthorization(const char * user, const char * password);
void setAuthorization(const char * auth);
void setAuthorization(String auth);
void setTimeout(uint16_t timeout);

// Redirections
Expand Down

0 comments on commit 058ce7c

Please sign in to comment.