Reqwest client, how to update headers?

I'm a newbie to rust and I've been getting buy with the docs and online help but now I'm stumped.

I'm calling a server (for a game*) and I want to log in. I have this working in culr(1), python, and even perl but not rust.

I set-up a client with reqwest::Client::builder() and can call the landing page.
On the next call to login I want to add a Referer header to my client, but I can't seem to do this.

The call I'm trying to make is :

pub async fn get_kol_data(
    mut client: Client,
    uri: String,
    form_data: Form,
    body_data: String) {
....
    let response = client.post(uri)
        .header(
            reqwest::header::REFERER,
            reqwest::header::HeaderValue::from_static(
                "Why doesn't this work?"))
        .multipart(form_data)
        .body(body_data)
        .send()
        .await
        .expect("Failed to get a response.");
...
}

If you can't update the headers of the client what's the point of reusing the client? It would need to be recreated on multiple calls. So I must be missing something in my understanding.

Many thanks for any help or guidance,

D

*KingdomOfLoathing if you must know. Been going for almost 20 years.

That code does work for setting a header on a request. If you want to set headers that are applied on every request you need build a new client to set them on. You can use ClientBuilder::default_headers to configure headers that are set on every request made through a client.

Client::builder()
    .default_headers(
        [(
            reqwest::header::REFERER,
            reqwest::header::HeaderValue::from_static("Default Value"),
        )]
        .into_iter()
        .collect(),
    )
    .build()
    .unwrap()

Thanks for the swift reply.

Yes, I have used ClientBuilder to set-up the specific headers for the initial call and was hoping to reused the client and either update or replace the headers that needed to change.

Looks like I'll have to change my code a little to handle making a new client for most calls. A little inefficient but nothing that will be noticeable to a person.