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

a few minor nits #2477

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

test:
name: ${{ matrix.name }}
needs: [style]
needs: [ style ]

runs-on: ${{ matrix.os || 'ubuntu-latest' }}

Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:

unstable:
name: "unstable features"
needs: [style]
needs: [ style ]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -222,7 +222,7 @@ jobs:

docs:
name: Docs
needs: [test]
needs: [ test ]
runs-on: ubuntu-latest

steps:
Expand All @@ -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
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:

msrv:
name: MSRV
needs: [style]
needs: [ style ]

runs-on: ubuntu-latest

Expand Down Expand Up @@ -307,7 +307,7 @@ jobs:

android:
name: Android
needs: [style]
needs: [ style ]

runs-on: ubuntu-latest

Expand All @@ -326,7 +326,7 @@ jobs:

wasm:
name: WASM
needs: [style]
needs: [ style ]

runs-on: ubuntu-latest

Expand Down
4 changes: 2 additions & 2 deletions examples/wasm_github_fetch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
3 changes: 1 addition & 2 deletions src/async_impl/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ where
}
}

pub(crate) type ResponseBody =
http_body_util::combinators::BoxBody<Bytes, Box<dyn std::error::Error + Send + Sync>>;
pub(crate) type ResponseBody = BoxBody<Bytes, Box<dyn std::error::Error + Send + Sync>>;

pub(crate) fn boxed<B>(body: B) -> ResponseBody
where
Expand Down
38 changes: 15 additions & 23 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down Expand Up @@ -542,23 +542,21 @@ 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();
for err in load_results.errors {
let _ = writeln!(&mut acc, "{err}");
}

crate::error::builder(acc)
error::builder(acc)
};

return Err(err);
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
};
Expand Down Expand Up @@ -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`",
));
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2655,15 +2651,15 @@ 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())
));
}
}

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())
));
}
}
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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())));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async_impl/h3_client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PoolClient> {
Expand Down
2 changes: 1 addition & 1 deletion src/async_impl/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/async_impl/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/async_impl/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl<T: Into<Body>> From<http::Response<T>> 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)),
Expand Down
4 changes: 2 additions & 2 deletions src/blocking/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/blocking/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
30 changes: 9 additions & 21 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"))
Expand Down Expand Up @@ -984,7 +984,7 @@ mod native_tls_conn {
self: Pin<&mut Self>,
cx: &mut Context,
buf: ReadBufCursor<'_>,
) -> Poll<tokio::io::Result<()>> {
) -> Poll<io::Result<()>> {
let this = self.project();
Read::poll_read(this.inner, cx, buf)
}
Expand All @@ -995,7 +995,7 @@ mod native_tls_conn {
self: Pin<&mut Self>,
cx: &mut Context,
buf: &[u8],
) -> Poll<Result<usize, tokio::io::Error>> {
) -> Poll<Result<usize, io::Error>> {
let this = self.project();
Write::poll_write(this.inner, cx, buf)
}
Expand All @@ -1013,18 +1013,12 @@ mod native_tls_conn {
self.inner.is_write_vectored()
}

fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context,
) -> Poll<Result<(), tokio::io::Error>> {
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
let this = self.project();
Write::poll_flush(this.inner, cx)
}

fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context,
) -> Poll<Result<(), tokio::io::Error>> {
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
let this = self.project();
Write::poll_shutdown(this.inner, cx)
}
Expand Down Expand Up @@ -1099,7 +1093,7 @@ mod rustls_tls_conn {
self: Pin<&mut Self>,
cx: &mut Context,
buf: ReadBufCursor<'_>,
) -> Poll<tokio::io::Result<()>> {
) -> Poll<io::Result<()>> {
let this = self.project();
Read::poll_read(this.inner, cx, buf)
}
Expand All @@ -1110,7 +1104,7 @@ mod rustls_tls_conn {
self: Pin<&mut Self>,
cx: &mut Context,
buf: &[u8],
) -> Poll<Result<usize, tokio::io::Error>> {
) -> Poll<Result<usize, io::Error>> {
let this = self.project();
Write::poll_write(this.inner, cx, buf)
}
Expand All @@ -1128,18 +1122,12 @@ mod rustls_tls_conn {
self.inner.is_write_vectored()
}

fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context,
) -> Poll<Result<(), tokio::io::Error>> {
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
let this = self.project();
Write::poll_flush(this.inner, cx)
}

fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context,
) -> Poll<Result<(), tokio::io::Error>> {
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
let this = self.project();
Write::poll_shutdown(this.inner, cx)
}
Expand Down
Loading
Loading