bendsql icon indicating copy to clipboard operation
bendsql copied to clipboard

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

Open youngsofun opened this issue 1 year ago • 4 comments

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 avatar Aug 22 '24 03:08 youngsofun

I will fix it in next pr by the way

youngsofun avatar Aug 22 '24 06:08 youngsofun

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

sundy-li avatar Aug 22 '24 07:08 sundy-li

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?

youngsofun avatar Aug 22 '24 11:08 youngsofun

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.

sundy-li avatar Aug 22 '24 12:08 sundy-li