Skip to content

Commit

Permalink
Basic auth from URI provided username/password
Browse files Browse the repository at this point in the history
  • Loading branch information
algesten committed Jan 3, 2025
1 parent e7a535a commit 1c52630
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/client/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,4 +934,19 @@ mod test {

assert_eq!(err, Error::BodyContentAfterFinish);
}

#[test]
fn username_password_uri() {
let req = Request::get("http://martin:secret@f.test/page")
.body(())
.unwrap();
let mut call = Call::without_body(req).unwrap();

let mut output = vec![0; 1024];
let n = call.write(&mut output).unwrap();

let s = str::from_utf8(&output[..n]).unwrap();

assert_eq!(s, "GET /page HTTP/1.1\r\nhost: f.test\r\nAuthorization: Basic bWFydGluOnNlY3JldA==\r\n\r\n");
}
}

0 comments on commit 1c52630

Please sign in to comment.