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 [#2024]: https://github.com/actix/actix-web/pull/2024
[#2050]: https://github.com/actix/actix-web/pull/2050 [#2050]: https://github.com/actix/actix-web/pull/2050
## 3.0.0-beta.2 - 2021-02-10 ## 3.0.0-beta.2 - 2021-02-10
### Added ### Added
* `ClientRequest::insert_header` method which allows using typed headers. [#1869] * `ClientRequest::insert_header` method which allows using typed headers. [#1869]

View File

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