diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f9c4fbdf..045965044 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: test: name: ${{ matrix.name }} - needs: [style] + needs: [ style ] runs-on: ${{ matrix.os || 'ubuntu-latest' }} @@ -203,7 +203,7 @@ jobs: unstable: name: "unstable features" - needs: [style] + needs: [ style ] runs-on: ubuntu-latest steps: - name: Checkout @@ -222,7 +222,7 @@ jobs: docs: name: Docs - needs: [test] + needs: [ test ] runs-on: ubuntu-latest steps: @@ -241,7 +241,7 @@ jobs: # job level. See `jobs.build.strategy.matrix`. nightly: name: linux / nightly - needs: [style] + needs: [ style ] # Use Ubuntu 20.04 here, because latest (22.04) uses OpenSSL v3. # Currently, OpenSSL v3 causes compile issues with openssl-sys @@ -274,7 +274,7 @@ jobs: msrv: name: MSRV - needs: [style] + needs: [ style ] runs-on: ubuntu-latest @@ -307,7 +307,7 @@ jobs: android: name: Android - needs: [style] + needs: [ style ] runs-on: ubuntu-latest @@ -326,7 +326,7 @@ jobs: wasm: name: WASM - needs: [style] + needs: [ style ] runs-on: ubuntu-latest diff --git a/examples/wasm_github_fetch/Cargo.toml b/examples/wasm_github_fetch/Cargo.toml index 193370f22..9bf54a7e3 100644 --- a/examples/wasm_github_fetch/Cargo.toml +++ b/examples/wasm_github_fetch/Cargo.toml @@ -10,9 +10,9 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -reqwest = {path = "../../"} +reqwest = { path = "../.." } serde = { version = "1.0.101", features = ["derive"] } serde_derive = "^1.0.59" wasm-bindgen-futures = "0.4.1" serde_json = "1.0.41" -wasm-bindgen = { version = "0.2.51", features = ["serde-serialize"] } +wasm-bindgen = { version = "0.2.51", features = ["serde-serialize"] } diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index 454046dd0..858b34291 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -389,8 +389,7 @@ where } } -pub(crate) type ResponseBody = - http_body_util::combinators::BoxBody>; +pub(crate) type ResponseBody = BoxBody>; pub(crate) fn boxed(body: B) -> ResponseBody where diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 71864fb3b..28f231831 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -437,7 +437,7 @@ impl ClientBuilder { // TLS v1.3. This would be entirely reasonable, // native-tls just doesn't support it. // https://github.com/sfackler/rust-native-tls/issues/140 - crate::error::builder("invalid minimum TLS version for backend") + error::builder("invalid minimum TLS version for backend") })?; tls.min_protocol_version(Some(protocol)); } @@ -448,7 +448,7 @@ impl ClientBuilder { // We could arguably do max_protocol_version(None), given // that 1.4 does not exist yet, but that'd get messy in the // future. - crate::error::builder("invalid maximum TLS version for backend") + error::builder("invalid maximum TLS version for backend") })?; tls.max_protocol_version(Some(protocol)); } @@ -542,15 +542,13 @@ impl ClientBuilder { Ok(_) => valid_count += 1, Err(err) => { invalid_count += 1; - log::debug!("rustls failed to parse DER certificate: {err:?}"); + debug!("rustls failed to parse DER certificate: {err:?}"); } } } if valid_count == 0 && invalid_count > 0 { let err = if load_results.errors.is_empty() { - crate::error::builder( - "zero valid certificates found in native root store", - ) + error::builder("zero valid certificates found in native root store") } else { use std::fmt::Write as _; let mut acc = String::new(); @@ -558,7 +556,7 @@ impl ClientBuilder { let _ = writeln!(&mut acc, "{err}"); } - crate::error::builder(acc) + error::builder(acc) }; return Err(err); @@ -589,7 +587,7 @@ impl ClientBuilder { } if versions.is_empty() { - return Err(crate::error::builder("empty supported tls versions")); + return Err(error::builder("empty supported tls versions")); } // Allow user to have installed a runtime default. @@ -609,7 +607,7 @@ impl ClientBuilder { let config_builder = rustls::ClientConfig::builder_with_provider(provider.clone()) .with_protocol_versions(&versions) - .map_err(|_| crate::error::builder("invalid TLS versions"))?; + .map_err(|_| error::builder("invalid TLS versions"))?; let config_builder = if !config.certs_verification { config_builder @@ -638,9 +636,7 @@ impl ClientBuilder { ) .with_crls(crls) .build() - .map_err(|_| { - crate::error::builder("invalid TLS verification settings") - })?; + .map_err(|_| error::builder("invalid TLS verification settings"))?; config_builder.with_webpki_verifier(verifier) } }; @@ -710,7 +706,7 @@ impl ClientBuilder { } #[cfg(any(feature = "native-tls", feature = "__rustls",))] TlsBackend::UnknownPreconfigured => { - return Err(crate::error::builder( + return Err(error::builder( "Unknown TLS backend passed to `use_preconfigured_tls`", )); } @@ -854,7 +850,7 @@ impl ClientBuilder { self.config.headers.insert(USER_AGENT, value); } Err(e) => { - self.config.error = Some(crate::error::builder(e.into())); + self.config.error = Some(error::builder(e.into())); } }; self @@ -2655,7 +2651,7 @@ impl Future for PendingRequest { if let Some(delay) = self.as_mut().total_timeout().as_mut().as_pin_mut() { if let Poll::Ready(()) = delay.poll(cx) { return Poll::Ready(Err( - crate::error::request(crate::error::TimedOut).with_url(self.url.clone()) + error::request(error::TimedOut).with_url(self.url.clone()) )); } } @@ -2663,7 +2659,7 @@ impl Future for PendingRequest { if let Some(delay) = self.as_mut().read_timeout().as_mut().as_pin_mut() { if let Poll::Ready(()) = delay.poll(cx) { return Poll::Ready(Err( - crate::error::request(crate::error::TimedOut).with_url(self.url.clone()) + error::request(error::TimedOut).with_url(self.url.clone()) )); } } @@ -2676,9 +2672,7 @@ impl Future for PendingRequest { if self.as_mut().retry_error(&e) { continue; } - return Poll::Ready(Err( - crate::error::request(e).with_url(self.url.clone()) - )); + return Poll::Ready(Err(error::request(e).with_url(self.url.clone()))); } Poll::Ready(Ok(res)) => res.map(super::body::boxed), Poll::Pending => return Poll::Pending, @@ -2689,9 +2683,7 @@ impl Future for PendingRequest { if self.as_mut().retry_error(&e) { continue; } - return Poll::Ready(Err( - crate::error::request(e).with_url(self.url.clone()) - )); + return Poll::Ready(Err(error::request(e).with_url(self.url.clone()))); } Poll::Ready(Ok(res)) => res, Poll::Pending => return Poll::Pending, @@ -2842,7 +2834,7 @@ impl Future for PendingRequest { debug!("redirect policy disallowed redirection to '{loc}'"); } redirect::ActionKind::Error(err) => { - return Poll::Ready(Err(crate::error::redirect(err, self.url.clone()))); + return Poll::Ready(Err(error::redirect(err, self.url.clone()))); } } } diff --git a/src/async_impl/h3_client/pool.rs b/src/async_impl/h3_client/pool.rs index 100a0935d..01f3ebee6 100644 --- a/src/async_impl/h3_client/pool.rs +++ b/src/async_impl/h3_client/pool.rs @@ -39,7 +39,7 @@ impl Pool { if !inner.connecting.insert(key.clone()) { return Err(format!("HTTP/3 connecting already in progress for {key:?}").into()); } - return Ok(()); + Ok(()) } pub fn try_pool(&self, key: &Key) -> Option { diff --git a/src/async_impl/multipart.rs b/src/async_impl/multipart.rs index 494bd5d9a..b016044d3 100644 --- a/src/async_impl/multipart.rs +++ b/src/async_impl/multipart.rs @@ -703,7 +703,7 @@ mod tests { let stream_len = stream_data.len(); let stream_data = stream_data .chunks(3) - .map(|c| Ok::<_, std::io::Error>(Bytes::from(c))); + .map(|c| Ok::<_, io::Error>(Bytes::from(c))); let the_stream = futures_util::stream::iter(stream_data); let bytes_data = b"some bytes data".to_vec(); diff --git a/src/async_impl/request.rs b/src/async_impl/request.rs index e20c7cfb3..2f732f5ef 100644 --- a/src/async_impl/request.rs +++ b/src/async_impl/request.rs @@ -181,7 +181,7 @@ impl RequestBuilder { pub fn from_parts(client: Client, request: Request) -> RequestBuilder { RequestBuilder { client, - request: crate::Result::Ok(request), + request: Ok(request), } } @@ -231,7 +231,7 @@ impl RequestBuilder { /// Add a set of Headers to the existing ones on this Request. /// /// The headers will be merged in to any already set. - pub fn headers(mut self, headers: crate::header::HeaderMap) -> RequestBuilder { + pub fn headers(mut self, headers: HeaderMap) -> RequestBuilder { if let Ok(ref mut req) = self.request { crate::util::replace_headers(req.headers_mut(), headers); } diff --git a/src/async_impl/response.rs b/src/async_impl/response.rs index cb2f4ec15..4eb8ef59a 100644 --- a/src/async_impl/response.rs +++ b/src/async_impl/response.rs @@ -453,7 +453,7 @@ impl> From> for Response { use crate::response::ResponseUrl; let (mut parts, body) = r.into_parts(); - let body: crate::async_impl::body::Body = body.into(); + let body: Body = body.into(); let decoder = Decoder::detect( &mut parts.headers, ResponseBody::new(body.map_err(Into::into)), diff --git a/src/blocking/multipart.rs b/src/blocking/multipart.rs index fc3222bec..47904229f 100644 --- a/src/blocking/multipart.rs +++ b/src/blocking/multipart.rs @@ -391,10 +391,10 @@ 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(io::empty())) .part("key1", Part::text("value1")) .part("key2", Part::text("value2").mime(mime::IMAGE_BMP)) - .part("reader2", Part::reader(std::io::empty())) + .part("reader2", Part::reader(io::empty())) .part("key3", Part::text("value3").file_name("filename")); form.inner.boundary = "boundary".to_string(); let length = form.compute_length(); diff --git a/src/blocking/request.rs b/src/blocking/request.rs index c2fe626ea..6e866e0d6 100644 --- a/src/blocking/request.rs +++ b/src/blocking/request.rs @@ -171,7 +171,7 @@ impl RequestBuilder { pub fn from_parts(client: Client, request: Request) -> RequestBuilder { RequestBuilder { client, - request: crate::Result::Ok(request), + request: Ok(request), } } @@ -255,7 +255,7 @@ impl RequestBuilder { /// # Ok(()) /// # } /// ``` - pub fn headers(mut self, headers: crate::header::HeaderMap) -> RequestBuilder { + pub fn headers(mut self, headers: HeaderMap) -> RequestBuilder { if let Ok(ref mut req) = self.request { crate::util::replace_headers(req.headers_mut(), headers); } diff --git a/src/connect.rs b/src/connect.rs index dfaf028a9..d1bdc9ee5 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -584,7 +584,7 @@ impl ConnectorService { fn into_uri(scheme: Scheme, host: Authority) -> Uri { // TODO: Should the `http` crate get `From<(Scheme, Authority)> for Uri`? - http::Uri::builder() + Uri::builder() .scheme(scheme) .authority(host) .path_and_query(http::uri::PathAndQuery::from_static("/")) @@ -984,7 +984,7 @@ mod native_tls_conn { self: Pin<&mut Self>, cx: &mut Context, buf: ReadBufCursor<'_>, - ) -> Poll> { + ) -> Poll> { let this = self.project(); Read::poll_read(this.inner, cx, buf) } @@ -995,7 +995,7 @@ mod native_tls_conn { self: Pin<&mut Self>, cx: &mut Context, buf: &[u8], - ) -> Poll> { + ) -> Poll> { let this = self.project(); Write::poll_write(this.inner, cx, buf) } @@ -1013,18 +1013,12 @@ mod native_tls_conn { self.inner.is_write_vectored() } - fn poll_flush( - self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll> { + fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let this = self.project(); Write::poll_flush(this.inner, cx) } - fn poll_shutdown( - self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll> { + fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let this = self.project(); Write::poll_shutdown(this.inner, cx) } @@ -1099,7 +1093,7 @@ mod rustls_tls_conn { self: Pin<&mut Self>, cx: &mut Context, buf: ReadBufCursor<'_>, - ) -> Poll> { + ) -> Poll> { let this = self.project(); Read::poll_read(this.inner, cx, buf) } @@ -1110,7 +1104,7 @@ mod rustls_tls_conn { self: Pin<&mut Self>, cx: &mut Context, buf: &[u8], - ) -> Poll> { + ) -> Poll> { let this = self.project(); Write::poll_write(this.inner, cx, buf) } @@ -1128,18 +1122,12 @@ mod rustls_tls_conn { self.inner.is_write_vectored() } - fn poll_flush( - self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll> { + fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let this = self.project(); Write::poll_flush(this.inner, cx) } - fn poll_shutdown( - self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll> { + fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let this = self.project(); Write::poll_shutdown(this.inner, cx) } diff --git a/src/error.rs b/src/error.rs index 6a9f07e51..84b760b82 100644 --- a/src/error.rs +++ b/src/error.rs @@ -358,7 +358,7 @@ mod tests { let root = Error::new(Kind::Request, None::); assert!(root.source().is_none()); - let link = super::body(root); + let link = body(root); assert!(link.source().is_some()); assert_send::(); assert_sync::(); @@ -372,11 +372,11 @@ mod tests { #[test] fn roundtrip_io_error() { - let orig = super::request("orig"); + let orig = request("orig"); // Convert reqwest::Error into an io::Error... let io = orig.into_io(); // Convert that io::Error back into a reqwest::Error... - let err = super::decode_io(io); + let err = decode_io(io); // It should have pulled out the original, not nested it... match err.inner.kind { Kind::Request => (), @@ -387,7 +387,7 @@ mod tests { #[test] fn from_unknown_io_error() { let orig = io::Error::new(io::ErrorKind::Other, "orly"); - let err = super::decode_io(orig); + let err = decode_io(orig); match err.inner.kind { Kind::Decode => (), _ => panic!("{err:?}"), @@ -396,11 +396,11 @@ mod tests { #[test] fn is_timeout() { - let err = super::request(super::TimedOut); + let err = request(TimedOut); assert!(err.is_timeout()); let io = io::Error::new(io::ErrorKind::Other, err); - let nested = super::request(io); + let nested = request(io); assert!(nested.is_timeout()); } } diff --git a/src/lib.rs b/src/lib.rs index cf3d39d0f..4f4203c9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,7 +237,7 @@ //! [get]: ./fn.get.html //! [builder]: ./struct.RequestBuilder.html //! [serde]: http://serde.rs -//! [redirect]: crate::redirect +//! [redirect]: redirect //! [Proxy]: ./struct.Proxy.html //! [cargo-features]: https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-features-section //! [sponsor]: https://seanmonstar.com/sponsor @@ -306,7 +306,7 @@ pub use self::response::ResponseBuilderExt; /// - supplied `Url` cannot be parsed /// - there was an error while sending request /// - redirect limit was exhausted -pub async fn get(url: T) -> crate::Result { +pub async fn get(url: T) -> Result { Client::builder().build()?.get(url).send().await } diff --git a/src/proxy.rs b/src/proxy.rs index f93b00f95..43d7acbe0 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -437,7 +437,7 @@ impl fmt::Debug for Proxy { impl NoProxy { /// Returns a new no-proxy configuration based on environment variables (or `None` if no variables are set) - /// see [self::NoProxy::from_string()] for the string format + /// see [NoProxy::from_string()] for the string format pub fn from_env() -> Option { let raw = env::var("NO_PROXY") .or_else(|_| env::var("no_proxy")) @@ -1146,7 +1146,7 @@ mod tests { #[cfg(feature = "socks")] _ => panic!("intercepted as socks"), }; - http::Uri::builder() + Uri::builder() .scheme(scheme) .authority(host) .path_and_query("/") diff --git a/src/tls.rs b/src/tls.rs index 0d5a161bd..83820302d 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -204,10 +204,7 @@ impl Certificate { } #[cfg(feature = "__rustls")] - pub(crate) fn add_to_rustls( - self, - root_cert_store: &mut rustls::RootCertStore, - ) -> crate::Result<()> { + pub(crate) fn add_to_rustls(self, root_cert_store: &mut RootCertStore) -> crate::Result<()> { use std::io::Cursor; match self.original { @@ -736,8 +733,8 @@ impl TlsInfo { } } -impl std::fmt::Debug for TlsInfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { +impl fmt::Debug for TlsInfo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("TlsInfo").finish() } } diff --git a/tests/support/delay_server.rs b/tests/support/delay_server.rs index f79c2a4df..521e1e023 100644 --- a/tests/support/delay_server.rs +++ b/tests/support/delay_server.rs @@ -44,8 +44,7 @@ impl Server { let addr = tcp_listener.local_addr().unwrap(); tokio::spawn(async move { - let mut builder = - hyper_util::server::conn::auto::Builder::new(hyper_util::rt::TokioExecutor::new()); + let mut builder = Builder::new(hyper_util::rt::TokioExecutor::new()); apply_config(&mut builder); tokio::spawn(async move { diff --git a/tests/support/server.rs b/tests/support/server.rs index 79ebd2d8f..511f91985 100644 --- a/tests/support/server.rs +++ b/tests/support/server.rs @@ -93,7 +93,7 @@ where .spawn(move || { rt.block_on(async move { let mut builder = - hyper_util::server::conn::auto::Builder::new(hyper_util::rt::TokioExecutor::new()); + Builder::new(hyper_util::rt::TokioExecutor::new()); apply_config(&mut builder); loop {