Don't set User-Agent header by default (#751)

This commit is contained in:
Sean McArthur
2019-12-23 12:48:11 -08:00
committed by GitHub
parent 47734f55f4
commit 09e7fe62e3
4 changed files with 111 additions and 15 deletions

View File

@@ -1,3 +1,4 @@
use std::convert::TryInto;
use std::fmt;
use std::future::Future;
use std::net::IpAddr;
@@ -5,6 +6,7 @@ use std::sync::Arc;
use std::thread;
use std::time::Duration;
use http::header::HeaderValue;
use log::{error, trace};
use tokio::sync::{mpsc, oneshot};
@@ -85,6 +87,35 @@ impl ClientBuilder {
// Higher-level options
/// Sets the `User-Agent` header to be used by this client.
///
/// # Example
///
/// ```rust
/// # fn doc() -> Result<(), reqwest::Error> {
/// // Name your user agent after your app?
/// static APP_USER_AGENT: &str = concat!(
/// env!("CARGO_PKG_NAME"),
/// "/",
/// env!("CARGO_PKG_VERSION"),
/// );
///
/// let client = reqwest::blocking::Client::builder()
/// .user_agent(APP_USER_AGENT)
/// .build()?;
/// let res = client.get("https://www.rust-lang.org").send()?;
/// # Ok(())
/// # }
/// ```
pub fn user_agent<V>(self, value: V) -> ClientBuilder
where
V: TryInto<HeaderValue>,
V::Error: Into<http::Error>,
{
self.with_inner(move |inner| inner.user_agent(value))
}
/// Sets the default headers for every request.
///
/// # Example