feat(client): add an accessor for the request body

Allow users to access the body of the request.
Useful when one wants to modify the request based
on the data in the body, e.g. to add checksum headers.
This commit is contained in:
James Kay
2017-04-19 17:39:28 +01:00
parent bb7c9b9430
commit 4e26646aa7

View File

@@ -33,7 +33,7 @@ impl<B> Request<B> {
/// Read the Request Uri. /// Read the Request Uri.
#[inline] #[inline]
pub fn uri(&self) -> &Uri { &self.uri } pub fn uri(&self) -> &Uri { &self.uri }
/// Read the Request Version. /// Read the Request Version.
#[inline] #[inline]
pub fn version(&self) -> HttpVersion { self.version } pub fn version(&self) -> HttpVersion { self.version }
@@ -46,6 +46,10 @@ impl<B> Request<B> {
#[inline] #[inline]
pub fn method(&self) -> &Method { &self.method } pub fn method(&self) -> &Method { &self.method }
/// Read the Request body.
#[inline]
pub fn body(&self) -> Option<&B> { self.body.as_ref() }
/// Set the Method of this request. /// Set the Method of this request.
#[inline] #[inline]
pub fn set_method(&mut self, method: Method) { self.method = method; } pub fn set_method(&mut self, method: Method) { self.method = method; }