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

bug: call self.auth.wrap(builder) when retry not work as what we expect. #477

Open
youngsofun opened this issue Aug 22, 2024 · 4 comments
Open

Comments

@youngsofun
Copy link
Member

youngsofun commented Aug 22, 2024

If I understand correctly, we call it again in retry, in order to reload token from file,
so it should be an overwrite of the old header value.

but the impl in reqwest is append

#[tokio::main]
async fn main() {
 
    let client = reqwest::Client::new();
    let mut req = client.delete("http://httpbin.org/delete")
    .header(reqwest::header::AUTHORIZATION, "password") // .basic_auth almost do the same, except is_sensitive
    .header(reqwest::header::AUTHORIZATION, "password2")
    .build().unwrap();
    println!("{:?}", req.headers());
    
    req.headers_mut().insert(reqwest::header::AUTHORIZATION, reqwest::header::HeaderValue::from_static("password3"));
    println!("{:?}", req.headers());
}

print:

Standard Output
{"authorization": "password", "authorization": "password2"}
{"authorization": "password3"}
@youngsofun youngsofun changed the title bug: call self.auth.wrap(builder) not work as what we expect. bug: call self.auth.wrap(builder) when retry not work as what we expect. Aug 22, 2024
@youngsofun
Copy link
Member Author

I will fix it in next pr by the way

@sundy-li
Copy link
Member

HTTP/1.1 allows header key with the same name yet HTTP/2 will duplicate the key with same name

@youngsofun
Copy link
Member Author

HTTP/1.1 allows header key with the same name yet HTTP/2 will duplicate the key with same name

so which one will be kept? the first or the last?

@sundy-li
Copy link
Member

so which one will be kept? the first or the last?
I don't know, maybe we should add function in reqwest to override the header.

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

No branches or pull requests

2 participants