Add user agent to HTTP requests

This commit is contained in:
Matteo Settenvini 2022-07-02 20:55:03 +02:00
parent bc9ca47e3e
commit 3c27383bbc
Signed by: matteo
GPG Key ID: 8576CC1AD97D42DF
3 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
use {
crate::constants::USER_AGENT,
anyhow::{anyhow, Result},
reqwest::{StatusCode, Url},
serde::{Deserialize, Serialize},
@ -46,7 +47,9 @@ impl Credentials {
}
pub fn add(&mut self, server: Url) -> Result<()> {
let http_client = reqwest::blocking::Client::new();
let http_client = reqwest::blocking::Client::builder()
.user_agent(USER_AGENT)
.build()?;
#[derive(Deserialize)]
struct LoginFlow {

4
src/constants.rs Normal file
View File

@ -0,0 +1,4 @@
// SPDX-FileCopyrightText: 2022 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
// SPDX-License-Identifier: AGPL-3.0-or-later
pub const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
mod config;
mod constants;
use {
self::config::Config,