From 200cae19a9e21e2d24e57bd37f434cfce6c36a7d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 5 Mar 2019 14:39:06 -0800 Subject: [PATCH] add HttpMessage impl &mut T --- src/httpmessage.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/httpmessage.rs b/src/httpmessage.rs index 17447af63..d95f82f5d 100644 --- a/src/httpmessage.rs +++ b/src/httpmessage.rs @@ -270,6 +270,37 @@ pub trait HttpMessage: Sized { } } +impl<'a, T> HttpMessage for &'a mut T +where + T: HttpMessage, +{ + type Stream = T::Stream; + + fn headers(&self) -> &HeaderMap { + (**self).headers() + } + + /// Mutable reference to the message's headers. + fn headers_mut(&mut self) -> &mut HeaderMap { + (**self).headers_mut() + } + + /// Message payload stream + fn take_payload(&mut self) -> Payload { + (**self).take_payload() + } + + /// Request's extensions container + fn extensions(&self) -> Ref { + (**self).extensions() + } + + /// Mutable reference to a the request's extensions container + fn extensions_mut(&self) -> RefMut { + (**self).extensions_mut() + } +} + /// Stream to read request line by line. pub struct Readlines { stream: Payload,