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

Unable to remove Accept header #1073

Closed
Ssaely opened this issue Nov 1, 2020 · 1 comment
Closed

Unable to remove Accept header #1073

Ssaely opened this issue Nov 1, 2020 · 1 comment

Comments

@Ssaely
Copy link

Ssaely commented Nov 1, 2020

I've been using reqwest and I've noticed that it sends the Accept header despite me not manually setting this header.

There also seems to be no way to remove this header as it is is stored in the ClientBuilder's config.

@stevelr
Copy link
Contributor

stevelr commented Nov 13, 2020

@Ssaely It's true that you can't delete the ACCEPT header, but you can replace its value in the ClientBuilder:

use reqwest::{Client,header::{HeaderMap,HeaderValue,ACCEPT}};

let mut headers = HeaderMap::new();
headers.insert(ACCEPT, HeaderValue::from_static("application/json"));
let client = Client::builder()
    .default_headers(headers)
    .build()?;

It's usually useful to set this header. If you're a Rust fan, think of it as adding type-checking to HTTP :-)

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