Skip to content

Commit

Permalink
rwf2#1067: Fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jespersm committed Sep 26, 2024
1 parent 0f7c075 commit 368288e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/lib/src/request/from_request_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ macro_rules! typed_headers_from_request {
#[rocket::async_trait]
impl<'r> FromRequest<'r> for $name {
type Error = headers::Error;
async fn from_request(req: &'r Request<'_>) -> crate::request::Outcome<Self, Self::Error> {
async fn from_request(req: &'r Request<'_>) ->
crate::request::Outcome<Self, Self::Error> {
req.headers().get($name::name().as_str()).next().or_forward(Status::NotFound)
.and_then(|h| HHeaderValue::from_str(h).or_error(Status::BadRequest))
.map_error(|(s, _)| (s, headers::Error::invalid()))
.and_then(|h| $name::decode(&mut std::iter::once(&h)).or_forward(Status::BadRequest))
.and_then(|h| $name::decode(&mut std::iter::once(&h))
.or_forward(Status::BadRequest))
}
}
)*)
}

macro_rules! generic_typed_headers_from_request {
($($name:ident<$bound:ident>),*) => ($(
pub use crate::http::$name;
Expand All @@ -29,15 +31,17 @@ macro_rules! generic_typed_headers_from_request {
impl<'r, T1: 'static + $bound> FromRequest<'r> for $name<T1> {
type Error = headers::Error;
async fn from_request(req: &'r Request<'_>) -> crate::request::Outcome<Self, Self::Error> {
req.headers().get($name::<T1>::name().as_str()).next().or_forward(Status::NotFound)
req.headers().get($name::<T1>::name().as_str()).next()
.or_forward(Status::NotFound)
.and_then(|h| HHeaderValue::from_str(h).or_error(Status::BadRequest))
.map_error(|(s, _)| (s, headers::Error::invalid()))
.and_then(|h| $name::decode(&mut std::iter::once(&h)).or_forward(Status::BadRequest))
.and_then(|h| $name::decode(&mut std::iter::once(&h))
.or_forward(Status::BadRequest))
}
}
)*)
}

// The following headers from 'headers' 0.4 are not imported, since they are
// provided by other Rocket features.

Expand Down Expand Up @@ -100,4 +104,3 @@ generic_typed_headers_from_request! {
Authorization<Credentials>, // Authorization header, defined in RFC7235
ProxyAuthorization<Credentials> // Proxy-Authorization header, defined in RFC7235
}

0 comments on commit 368288e

Please sign in to comment.