@@ -156,7 +156,8 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
156
156
// auth info
157
157
String auth = host.substring (0 , index );
158
158
host.remove (0 , index + 1 ); // remove auth part including @
159
- _base64Authorization = base64::encode (auth);
159
+ _rawAuthorization = " Basic " ;
160
+ _rawAuthorization += base64::encode (auth);
160
161
}
161
162
162
163
// get port
@@ -269,7 +270,7 @@ void HTTPClient::setUserAgent(const String& userAgent)
269
270
}
270
271
271
272
/* *
272
- * set the Authorizatio for the http request
273
+ * set the Authorization for the http request
273
274
* @param user const char *
274
275
* @param password const char *
275
276
*/
@@ -279,18 +280,31 @@ void HTTPClient::setAuthorization(const char * user, const char * password)
279
280
String auth = user;
280
281
auth += " :" ;
281
282
auth += password;
282
- _base64Authorization = base64::encode (auth);
283
+ _rawAuthorization = " Basic " ;
284
+ _rawAuthorization += base64::encode (auth);
283
285
}
284
286
}
285
287
286
288
/* *
287
- * set the Authorizatio for the http request
289
+ * set the Authorization for the http request
288
290
* @param auth const char * base64
289
291
*/
290
292
void HTTPClient::setAuthorization (const char * auth)
291
293
{
292
294
if (auth) {
293
- _base64Authorization = auth;
295
+ _rawAuthorization = " Basic " ;
296
+ _rawAuthorization += auth;
297
+ }
298
+ }
299
+
300
+ /* *
301
+ * set the full raw Authorization header value for the http request
302
+ * @param rawAuth const char *
303
+ */
304
+ void HTTPClient::setRawAuthorization (const char * rawAuth)
305
+ {
306
+ if (rawAuth) {
307
+ _rawAuthorization = rawAuth;
294
308
}
295
309
}
296
310
@@ -742,7 +756,7 @@ void HTTPClient::addHeader(const String& name, const String& value, bool first,
742
756
if (!name.equalsIgnoreCase (F (" Connection" )) &&
743
757
!name.equalsIgnoreCase (F (" User-Agent" )) &&
744
758
!name.equalsIgnoreCase (F (" Host" )) &&
745
- !(name.equalsIgnoreCase (F (" Authorization" )) && _base64Authorization .length ())){
759
+ !(name.equalsIgnoreCase (F (" Authorization" )) && _rawAuthorization .length ())){
746
760
747
761
String headerLine = name;
748
762
headerLine += " : " ;
@@ -901,10 +915,10 @@ bool HTTPClient::sendHeader(const char * type)
901
915
header += F (" Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0\r\n " );
902
916
}
903
917
904
- if (_base64Authorization .length ()) {
905
- _base64Authorization .replace (" \n " , " " );
906
- header += F (" Authorization: Basic " );
907
- header += _base64Authorization ;
918
+ if (_rawAuthorization .length ()) {
919
+ _rawAuthorization .replace (" \n " , " " );
920
+ header += F (" Authorization: " );
921
+ header += _rawAuthorization ;
908
922
header += " \r\n " ;
909
923
}
910
924
0 commit comments