From 2c1571881e9eb7236a41adc3df61726eb4008aa0 Mon Sep 17 00:00:00 2001 From: Jordan Johnson-Doyle Date: Tue, 12 Feb 2019 01:22:47 +0000 Subject: [PATCH] No need to clone the Host header --- src/params.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/params.rs b/src/params.rs index 2e08228..e8b7930 100644 --- a/src/params.rs +++ b/src/params.rs @@ -24,12 +24,16 @@ impl<'a, 'r> FromRequest<'a, 'r> for IsPlaintextRequest { } } -pub struct HostHeader(pub Option); +/// Gets the Host header from the request. +/// +/// The inner value of this `HostHeader` will be `None` if there was no Host header +/// on the request. +pub struct HostHeader<'a>(pub Option<&'a str>); -impl<'a, 'r> FromRequest<'a, 'r> for HostHeader { +impl<'a, 'r> FromRequest<'a, 'r> for HostHeader<'a> { type Error = (); - fn from_request(request: &'a Request<'r>) -> Outcome { - Outcome::Success(HostHeader(request.headers().get_one("Host").map(|h| h.to_string()))) + fn from_request(request: &'a Request<'r>) -> Outcome, ()> { + Outcome::Success(HostHeader(request.headers().get_one("Host"))) } } \ No newline at end of file -- libgit2 1.7.2