This commit is contained in:
Rob Ede 2021-03-07 17:25:49 +00:00
parent 3b642c8545
commit 26b9b3d29f
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 3 additions and 8 deletions

View File

@ -20,6 +20,7 @@
[#2024]: https://github.com/actix/actix-web/pull/2024
[#2050]: https://github.com/actix/actix-web/pull/2050
## 3.0.0-beta.2 - 2021-02-10
### Added
* `ClientRequest::insert_header` method which allows using typed headers. [#1869]

View File

@ -255,11 +255,7 @@ impl ClientRequest {
/// Set HTTP basic authorization header.
///
/// If no password is needed, just provide an empty string.
pub fn basic_auth(
self,
username: impl fmt::Display,
password: impl fmt::Display,
) -> Self {
pub fn basic_auth(self, username: impl fmt::Display, password: impl fmt::Display) -> Self {
let auth = format!("{}:{}", username, password);
self.insert_header((
@ -642,9 +638,7 @@ mod tests {
#[actix_rt::test]
async fn client_basic_auth() {
let req = Client::new()
.get("/")
.basic_auth("username", "password");
let req = Client::new().get("/").basic_auth("username", "password");
assert_eq!(
req.head
.headers