remove unnecessary double-colons
This commit is contained in:
committed by
Sean McArthur
parent
06353fbb1a
commit
4bb4149b63
@@ -48,7 +48,7 @@ impl Body {
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn empty() -> Body {
|
||||
Body::wrap(::hyper::Body::empty())
|
||||
Body::wrap(hyper::Body::empty())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -145,7 +145,7 @@ where
|
||||
{
|
||||
#[inline]
|
||||
fn from(s: Box<dyn Stream<Item = I, Error = E> + Send>) -> Body {
|
||||
Body::wrap(::hyper::Body::wrap_stream(s))
|
||||
Body::wrap(hyper::Body::wrap_stream(s))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ impl Extend<u8> for Chunk {
|
||||
impl IntoIterator for Chunk {
|
||||
type Item = u8;
|
||||
//XXX: exposing type from hyper!
|
||||
type IntoIter = <::hyper::Chunk as IntoIterator>::IntoIter;
|
||||
type IntoIter = <hyper::Chunk as IntoIterator>::IntoIter;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.inner.into_iter()
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ mod tests {
|
||||
.part("key1", Part::text("value1"))
|
||||
.part(
|
||||
"key2",
|
||||
Part::text("value2").mime(::mime::IMAGE_BMP),
|
||||
Part::text("value2").mime(mime::IMAGE_BMP),
|
||||
)
|
||||
.part("reader2", Part::stream(futures::stream::once::<_, hyper::Error>(Ok(hyper::Chunk::from("part2".to_owned())))))
|
||||
.part(
|
||||
@@ -515,12 +515,12 @@ mod tests {
|
||||
std::str::from_utf8(&out).unwrap()
|
||||
);
|
||||
println!("START EXPECTED\n{}\nEND EXPECTED", expected);
|
||||
assert_eq!(::std::str::from_utf8(&out).unwrap(), expected);
|
||||
assert_eq!(std::str::from_utf8(&out).unwrap(), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_to_end_with_header() {
|
||||
let mut part = Part::text("value2").mime(::mime::IMAGE_BMP);
|
||||
let mut part = Part::text("value2").mime(mime::IMAGE_BMP);
|
||||
part.meta.headers.insert("Hdr3", "/a/b/c".parse().unwrap());
|
||||
let mut form = Form::new().part("key2", part);
|
||||
form.inner.boundary = "boundary".to_string();
|
||||
|
||||
@@ -37,7 +37,7 @@ pub struct Response {
|
||||
}
|
||||
|
||||
impl Response {
|
||||
pub(super) fn new(res: hyper::Response<::hyper::Body>, url: Url, gzip: bool, timeout: Option<Delay>) -> Response {
|
||||
pub(super) fn new(res: hyper::Response<hyper::Body>, url: Url, gzip: bool, timeout: Option<Delay>) -> Response {
|
||||
let (parts, body) = res.into_parts();
|
||||
let status = parts.status;
|
||||
let version = parts.version;
|
||||
|
||||
@@ -387,7 +387,7 @@ pub(crate) type Conn = Box<dyn AsyncConn + Send + Sync + 'static>;
|
||||
pub(crate) type Connecting = Box<dyn Future<Item=(Conn, Connected), Error=io::Error> + Send>;
|
||||
|
||||
#[cfg(feature = "tls")]
|
||||
fn tunnel<T>(conn: T, host: String, port: u16, auth: Option<::http::header::HeaderValue>) -> Tunnel<T> {
|
||||
fn tunnel<T>(conn: T, host: String, port: u16, auth: Option<http::header::HeaderValue>) -> Tunnel<T> {
|
||||
let mut buf = format!("\
|
||||
CONNECT {0}:{1} HTTP/1.1\r\n\
|
||||
Host: {0}:{1}\r\n\
|
||||
|
||||
42
src/error.rs
42
src/error.rs
@@ -389,22 +389,22 @@ impl StdError for Error {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Kind {
|
||||
Http(::http::Error),
|
||||
Hyper(::hyper::Error),
|
||||
Mime(::mime::FromStrError),
|
||||
Url(::url::ParseError),
|
||||
Http(http::Error),
|
||||
Hyper(hyper::Error),
|
||||
Mime(mime::FromStrError),
|
||||
Url(url::ParseError),
|
||||
UrlBadScheme,
|
||||
#[cfg(all(feature = "default-tls", feature = "rustls-tls"))]
|
||||
TlsIncompatible,
|
||||
#[cfg(feature = "default-tls")]
|
||||
NativeTls(::native_tls::Error),
|
||||
NativeTls(native_tls::Error),
|
||||
#[cfg(feature = "rustls-tls")]
|
||||
Rustls(::rustls::TLSError),
|
||||
Rustls(rustls::TLSError),
|
||||
#[cfg(feature = "trust-dns")]
|
||||
DnsSystemConf(io::Error),
|
||||
Io(io::Error),
|
||||
UrlEncoded(::serde_urlencoded::ser::Error),
|
||||
Json(::serde_json::Error),
|
||||
UrlEncoded(serde_urlencoded::ser::Error),
|
||||
Json(serde_json::Error),
|
||||
TooManyRedirects,
|
||||
RedirectLoop,
|
||||
Status(StatusCode),
|
||||
@@ -414,21 +414,21 @@ pub(crate) enum Kind {
|
||||
}
|
||||
|
||||
|
||||
impl From<::http::Error> for Kind {
|
||||
impl From<http::Error> for Kind {
|
||||
#[inline]
|
||||
fn from(err: http::Error) -> Kind {
|
||||
Kind::Http(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::hyper::Error> for Kind {
|
||||
impl From<hyper::Error> for Kind {
|
||||
#[inline]
|
||||
fn from(err: hyper::Error) -> Kind {
|
||||
Kind::Hyper(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::mime::FromStrError> for Kind {
|
||||
impl From<mime::FromStrError> for Kind {
|
||||
#[inline]
|
||||
fn from(err: mime::FromStrError) -> Kind {
|
||||
Kind::Mime(err)
|
||||
@@ -442,21 +442,21 @@ impl From<io::Error> for Kind {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::url::ParseError> for Kind {
|
||||
impl From<url::ParseError> for Kind {
|
||||
#[inline]
|
||||
fn from(err: url::ParseError) -> Kind {
|
||||
Kind::Url(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::serde_urlencoded::ser::Error> for Kind {
|
||||
impl From<serde_urlencoded::ser::Error> for Kind {
|
||||
#[inline]
|
||||
fn from(err: serde_urlencoded::ser::Error) -> Kind {
|
||||
Kind::UrlEncoded(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::serde_json::Error> for Kind {
|
||||
impl From<serde_json::Error> for Kind {
|
||||
#[inline]
|
||||
fn from(err: serde_json::Error) -> Kind {
|
||||
Kind::Json(err)
|
||||
@@ -464,14 +464,14 @@ impl From<::serde_json::Error> for Kind {
|
||||
}
|
||||
|
||||
#[cfg(feature = "default-tls")]
|
||||
impl From<::native_tls::Error> for Kind {
|
||||
impl From<native_tls::Error> for Kind {
|
||||
fn from(err: native_tls::Error) -> Kind {
|
||||
Kind::NativeTls(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rustls-tls")]
|
||||
impl From<::rustls::TLSError> for Kind {
|
||||
impl From<rustls::TLSError> for Kind {
|
||||
fn from(err: rustls::TLSError) -> Kind {
|
||||
Kind::Rustls(err)
|
||||
}
|
||||
@@ -494,7 +494,7 @@ impl From<EnterError> for Kind {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::tokio::timer::Error> for Kind {
|
||||
impl From<tokio::timer::Error> for Kind {
|
||||
fn from(_err: tokio::timer::Error) -> Kind {
|
||||
Kind::Timer
|
||||
}
|
||||
@@ -577,7 +577,7 @@ macro_rules! try_io {
|
||||
match $e {
|
||||
Ok(v) => v,
|
||||
Err(ref err) if err.kind() == std::io::ErrorKind::WouldBlock => {
|
||||
return Ok(::futures::Async::NotReady);
|
||||
return Ok(futures::Async::NotReady);
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(crate::error::from_io(err));
|
||||
@@ -653,15 +653,15 @@ mod tests {
|
||||
}
|
||||
|
||||
let root = Chain(None::<Error>);
|
||||
let io = std::io::Error::new(::std::io::ErrorKind::Other, root);
|
||||
let io = std::io::Error::new(std::io::ErrorKind::Other, root);
|
||||
let err = Error::new(Kind::Io(io), None);
|
||||
assert!(err.cause().is_none());
|
||||
assert_eq!(err.to_string(), "root");
|
||||
|
||||
|
||||
let root = std::io::Error::new(::std::io::ErrorKind::Other, Chain(None::<Error>));
|
||||
let root = std::io::Error::new(std::io::ErrorKind::Other, Chain(None::<Error>));
|
||||
let link = Chain(Some(root));
|
||||
let io = std::io::Error::new(::std::io::ErrorKind::Other, link);
|
||||
let io = std::io::Error::new(std::io::ErrorKind::Other, link);
|
||||
let err = Error::new(Kind::Io(io), None);
|
||||
assert!(err.cause().is_some());
|
||||
assert_eq!(err.to_string(), "chain: root");
|
||||
|
||||
@@ -42,7 +42,7 @@ pub(crate) fn expect_uri(url: &Url) -> hyper::Uri {
|
||||
url.as_str().parse().expect("a parsed Url should always be a valid Uri")
|
||||
}
|
||||
|
||||
pub(crate) fn try_uri(url: &Url) -> Option<::hyper::Uri> {
|
||||
pub(crate) fn try_uri(url: &Url) -> Option<hyper::Uri> {
|
||||
url.as_str().parse().ok()
|
||||
}
|
||||
|
||||
|
||||
@@ -377,13 +377,13 @@ mod tests {
|
||||
fn read_to_end() {
|
||||
let mut output = Vec::new();
|
||||
let mut form = Form::new()
|
||||
.part("reader1", Part::reader(::std::io::empty()))
|
||||
.part("reader1", Part::reader(std::io::empty()))
|
||||
.part("key1", Part::text("value1"))
|
||||
.part(
|
||||
"key2",
|
||||
Part::text("value2").mime(::mime::IMAGE_BMP),
|
||||
Part::text("value2").mime(mime::IMAGE_BMP),
|
||||
)
|
||||
.part("reader2", Part::reader(::std::io::empty()))
|
||||
.part("reader2", Part::reader(std::io::empty()))
|
||||
.part(
|
||||
"key3",
|
||||
Part::text("value3").file_name("filename"),
|
||||
@@ -413,7 +413,7 @@ mod tests {
|
||||
std::str::from_utf8(&output).unwrap()
|
||||
);
|
||||
println!("START EXPECTED\n{}\nEND EXPECTED", expected);
|
||||
assert_eq!(::std::str::from_utf8(&output).unwrap(), expected);
|
||||
assert_eq!(std::str::from_utf8(&output).unwrap(), expected);
|
||||
assert!(length.is_none());
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ mod tests {
|
||||
.text("key1", "value1")
|
||||
.part(
|
||||
"key2",
|
||||
Part::text("value2").mime(::mime::IMAGE_BMP),
|
||||
Part::text("value2").mime(mime::IMAGE_BMP),
|
||||
)
|
||||
.part(
|
||||
"key3",
|
||||
@@ -449,14 +449,14 @@ mod tests {
|
||||
std::str::from_utf8(&output).unwrap()
|
||||
);
|
||||
println!("START EXPECTED\n{}\nEND EXPECTED", expected);
|
||||
assert_eq!(::std::str::from_utf8(&output).unwrap(), expected);
|
||||
assert_eq!(std::str::from_utf8(&output).unwrap(), expected);
|
||||
assert_eq!(length.unwrap(), expected.len() as u64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_to_end_with_header() {
|
||||
let mut output = Vec::new();
|
||||
let mut part = Part::text("value2").mime(::mime::IMAGE_BMP);
|
||||
let mut part = Part::text("value2").mime(mime::IMAGE_BMP);
|
||||
part.meta.headers.insert("Hdr3", "/a/b/c".parse().unwrap());
|
||||
let mut form = Form::new().part("key2", part);
|
||||
form.inner.boundary = "boundary".to_string();
|
||||
@@ -474,6 +474,6 @@ mod tests {
|
||||
std::str::from_utf8(&output).unwrap()
|
||||
);
|
||||
println!("START EXPECTED\n{}\nEND EXPECTED", expected);
|
||||
assert_eq!(::std::str::from_utf8(&output).unwrap(), expected);
|
||||
assert_eq!(std::str::from_utf8(&output).unwrap(), expected);
|
||||
}
|
||||
}
|
||||
|
||||
12
src/proxy.rs
12
src/proxy.rs
@@ -26,7 +26,7 @@ use winreg::RegKey;
|
||||
/// For instance, let's look at `Proxy::http`:
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let proxy = reqwest::Proxy::http("https://secure.example")?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
@@ -88,7 +88,7 @@ impl Proxy {
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::builder()
|
||||
/// .proxy(reqwest::Proxy::http("https://my.prox")?)
|
||||
/// .build()?;
|
||||
@@ -108,7 +108,7 @@ impl Proxy {
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::builder()
|
||||
/// .proxy(reqwest::Proxy::https("https://example.prox:4545")?)
|
||||
/// .build()?;
|
||||
@@ -128,7 +128,7 @@ impl Proxy {
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::builder()
|
||||
/// .proxy(reqwest::Proxy::all("http://pro.xy")?)
|
||||
/// .build()?;
|
||||
@@ -148,7 +148,7 @@ impl Proxy {
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let target = reqwest::Url::parse("https://my.prox")?;
|
||||
/// let client = reqwest::Client::builder()
|
||||
/// .proxy(reqwest::Proxy::custom(move |url| {
|
||||
@@ -190,7 +190,7 @@ impl Proxy {
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let proxy = reqwest::Proxy::https("http://localhost:1234")?
|
||||
/// .basic_auth("Aladdin", "open sesame");
|
||||
/// # Ok(())
|
||||
|
||||
@@ -130,7 +130,7 @@ impl RequestBuilder {
|
||||
/// ```rust
|
||||
/// use reqwest::header::USER_AGENT;
|
||||
///
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let res = client.get("https://www.rust-lang.org")
|
||||
/// .header(USER_AGENT, "foo")
|
||||
@@ -176,7 +176,7 @@ impl RequestBuilder {
|
||||
/// headers
|
||||
/// }
|
||||
///
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let file = fs::File::open("much_beauty.png")?;
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let res = client.post("http://httpbin.org/post")
|
||||
@@ -221,7 +221,7 @@ impl RequestBuilder {
|
||||
/// Enable HTTP basic authentication.
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let resp = client.delete("http://httpbin.org/delete")
|
||||
/// .basic_auth("admin", Some("good password"))
|
||||
@@ -245,7 +245,7 @@ impl RequestBuilder {
|
||||
/// Enable HTTP bearer authentication.
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let resp = client.delete("http://httpbin.org/delete")
|
||||
/// .bearer_auth("token")
|
||||
@@ -268,7 +268,7 @@ impl RequestBuilder {
|
||||
/// Using a string:
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let res = client.post("http://httpbin.org/post")
|
||||
/// .body("from a &str!")
|
||||
@@ -281,7 +281,7 @@ impl RequestBuilder {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use std::fs;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let file = fs::File::open("from_a_file.txt")?;
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let res = client.post("http://httpbin.org/post")
|
||||
@@ -295,7 +295,7 @@ impl RequestBuilder {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use std::fs;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// // from bytes!
|
||||
/// let bytes: Vec<u8> = vec![1, 10, 100];
|
||||
/// let client = reqwest::Client::new();
|
||||
@@ -517,7 +517,7 @@ impl RequestBuilder {
|
||||
/// With a static body
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let builder = client.post("http://httpbin.org/post")
|
||||
/// .body("from a &str!");
|
||||
@@ -530,7 +530,7 @@ impl RequestBuilder {
|
||||
/// Without a body
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let builder = client.get("http://httpbin.org/get");
|
||||
/// let clone = builder.try_clone();
|
||||
@@ -542,7 +542,7 @@ impl RequestBuilder {
|
||||
/// With a non-clonable body
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = reqwest::Client::new();
|
||||
/// let builder = client.get("http://httpbin.org/get")
|
||||
/// .body(reqwest::Body::new(std::io::empty()));
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Response {
|
||||
/// Checking for general status class:
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let resp = reqwest::get("http://httpbin.org/get")?;
|
||||
/// if resp.status().is_success() {
|
||||
/// println!("success!");
|
||||
@@ -62,7 +62,7 @@ impl Response {
|
||||
/// ```rust
|
||||
/// use reqwest::Client;
|
||||
/// use reqwest::StatusCode;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = Client::new();
|
||||
///
|
||||
/// let resp = client.post("http://httpbin.org/post")
|
||||
@@ -94,7 +94,7 @@ impl Response {
|
||||
/// use reqwest::Client;
|
||||
/// use reqwest::header::ETAG;
|
||||
///
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let client = Client::new();
|
||||
///
|
||||
/// let mut resp = client.get("http://httpbin.org/cache").send()?;
|
||||
@@ -133,7 +133,7 @@ impl Response {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let resp = reqwest::get("http://httpbin.org/redirect/1")?;
|
||||
/// assert_eq!(resp.url().as_str(), "http://httpbin.org/get");
|
||||
/// # Ok(())
|
||||
@@ -149,7 +149,7 @@ impl Response {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let resp = reqwest::get("http://httpbin.org/redirect/1")?;
|
||||
/// println!("httpbin.org address: {:?}", resp.remote_addr());
|
||||
/// # Ok(())
|
||||
@@ -222,7 +222,7 @@ impl Response {
|
||||
///
|
||||
/// ```rust
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let content = reqwest::get("http://httpbin.org/range/26")?.text()?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
@@ -249,7 +249,7 @@ impl Response {
|
||||
///
|
||||
/// ```rust
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let content = reqwest::get("http://httpbin.org/range/26")?.text_with_charset("utf-8")?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
@@ -281,7 +281,7 @@ impl Response {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let mut resp = reqwest::get("http://httpbin.org/range/5")?;
|
||||
/// let mut buf: Vec<u8> = vec![];
|
||||
/// resp.copy_to(&mut buf)?;
|
||||
@@ -302,7 +302,7 @@ impl Response {
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let res = reqwest::get("http://httpbin.org/status/400")?
|
||||
/// .error_for_status();
|
||||
/// if let Err(err) = res {
|
||||
@@ -331,7 +331,7 @@ impl Response {
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # extern crate reqwest;
|
||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||
/// # fn run() -> Result<(), Box<std::error::Error>> {
|
||||
/// let res = reqwest::get("http://httpbin.org/status/400")?;
|
||||
/// let res = res.error_for_status_ref();
|
||||
/// if let Err(err) = res {
|
||||
|
||||
10
src/tls.rs
10
src/tls.rs
@@ -27,11 +27,11 @@ pub struct Identity {
|
||||
|
||||
enum ClientCert {
|
||||
#[cfg(feature = "default-tls")]
|
||||
Pkcs12(::native_tls::Identity),
|
||||
Pkcs12(native_tls::Identity),
|
||||
#[cfg(feature = "rustls-tls")]
|
||||
Pem {
|
||||
key: rustls::PrivateKey,
|
||||
certs: Vec<::rustls::Certificate>,
|
||||
certs: Vec<rustls::Certificate>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ impl Certificate {
|
||||
pub fn from_der(der: &[u8]) -> crate::Result<Certificate> {
|
||||
Ok(Certificate {
|
||||
#[cfg(feature = "default-tls")]
|
||||
native: try_!(::native_tls::Certificate::from_der(der)),
|
||||
native: try_!(native_tls::Certificate::from_der(der)),
|
||||
#[cfg(feature = "rustls-tls")]
|
||||
original: Cert::Der(der.to_owned()),
|
||||
})
|
||||
@@ -81,7 +81,7 @@ impl Certificate {
|
||||
pub fn from_pem(pem: &[u8]) -> crate::Result<Certificate> {
|
||||
Ok(Certificate {
|
||||
#[cfg(feature = "default-tls")]
|
||||
native: try_!(::native_tls::Certificate::from_pem(pem)),
|
||||
native: try_!(native_tls::Certificate::from_pem(pem)),
|
||||
#[cfg(feature = "rustls-tls")]
|
||||
original: Cert::Pem(pem.to_owned())
|
||||
})
|
||||
@@ -152,7 +152,7 @@ impl Identity {
|
||||
pub fn from_pkcs12_der(der: &[u8], password: &str) -> crate::Result<Identity> {
|
||||
Ok(Identity {
|
||||
inner: ClientCert::Pkcs12(
|
||||
try_!(::native_tls::Identity::from_pkcs12(der, password))
|
||||
try_!(native_tls::Identity::from_pkcs12(der, password))
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user