Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support url with authority #716

Closed
wants to merge 1 commit into from
Closed

support url with authority #716

wants to merge 1 commit into from

Conversation

yangby-cryptape
Copy link

@yangby-cryptape yangby-cryptape commented Nov 20, 2019

For #715.

With this PR, the output of the example in #715 will be:

RequestBuilder {
    client: Client,
    request: Ok(
        Request {
            method: POST,
            url: "http://localhost:12345/",
            headers: {
                "authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
                "content-type": "application/json",
            },
        },
    ),
}

I checked the logs of nginx, this request was same as the request which sent by curl/7.65.0 with same url and same content.

  • If the modification in this PR was acceptable, I can pull another PR to the master branch.

if req.url.has_authority() {
let url = req.url.clone();
let username = url.username().to_owned();
let password = url.password().map(ToOwned::to_owned);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triple cloning here. Seems unecessary.
I doubt basic_auth needs an owned object, I am pretty sure you can implement that with absolutely no cloning, just using reference.

@seanmonstar
Copy link
Owner

I've made some modifications and opened #735, thanks for starting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants