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

Set HTTP Accept header #178

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use std::{

use error::Error;
use pico_args::Arguments;
use reqwest::Client;
use reqwest::{
header::{self, HeaderMap, HeaderName, HeaderValue},
Client,
};
use tokio::{
signal::unix::{signal, SignalKind},
sync::broadcast,
Expand Down Expand Up @@ -175,10 +178,22 @@ const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VE

const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);

const DEFAULT_HEADERS: &[(HeaderName, &str)] = &[(
header::ACCEPT,
"application/atom+xml, application/rss+xml, application/xml, text/xml",
)];

fn build_client() -> Result<Client> {
let headers = HeaderMap::from_iter(
DEFAULT_HEADERS
.iter()
.map(|(k, v)| (k.clone(), HeaderValue::from_static(v))),
);

let client = Client::builder()
.timeout(DEFAULT_TIMEOUT)
.user_agent(USER_AGENT)
.default_headers(headers)
.build()?;

Ok(client)
Expand Down