| @@ -1,5 +1,4 @@ | |||||||
| #![feature(macro_rules, phase, default_type_params, if_let, slicing_syntax, | #![feature(macro_rules, phase, default_type_params, slicing_syntax, globs)] | ||||||
|            tuple_indexing, globs)] |  | ||||||
| #![deny(missing_docs)] | #![deny(missing_docs)] | ||||||
| #![deny(warnings)] | #![deny(warnings)] | ||||||
| #![experimental] | #![experimental] | ||||||
|   | |||||||
| @@ -15,8 +15,6 @@ use http::HttpReader; | |||||||
| use http::HttpReader::{SizedReader, ChunkedReader, EmptyReader}; | use http::HttpReader::{SizedReader, ChunkedReader, EmptyReader}; | ||||||
| use uri::RequestUri; | use uri::RequestUri; | ||||||
|  |  | ||||||
| pub type InternalReader<'a> = &'a mut (Reader + 'a); |  | ||||||
|  |  | ||||||
| /// A request bundles several parts of an incoming `NetworkStream`, given to a `Handler`. | /// A request bundles several parts of an incoming `NetworkStream`, given to a `Handler`. | ||||||
| pub struct Request<'a> { | pub struct Request<'a> { | ||||||
|     /// The IP address of the remote connection. |     /// The IP address of the remote connection. | ||||||
| @@ -29,7 +27,7 @@ pub struct Request<'a> { | |||||||
|     pub uri: RequestUri, |     pub uri: RequestUri, | ||||||
|     /// The version of HTTP for this request. |     /// The version of HTTP for this request. | ||||||
|     pub version: HttpVersion, |     pub version: HttpVersion, | ||||||
|     body: HttpReader<InternalReader<'a>> |     body: HttpReader<&'a mut (Reader + 'a)> | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -37,7 +35,7 @@ impl<'a> Request<'a> { | |||||||
|  |  | ||||||
|     /// Create a new Request, reading the StartLine and Headers so they are |     /// Create a new Request, reading the StartLine and Headers so they are | ||||||
|     /// immediately useful. |     /// immediately useful. | ||||||
|     pub fn new(mut stream: InternalReader<'a>, addr: SocketAddr) -> HttpResult<Request<'a>> { |     pub fn new(mut stream: &'a mut (Reader + 'a), addr: SocketAddr) -> HttpResult<Request<'a>> { | ||||||
|         let (method, uri, version) = try!(read_request_line(&mut stream)); |         let (method, uri, version) = try!(read_request_line(&mut stream)); | ||||||
|         debug!("Request Line: {} {} {}", method, uri, version); |         debug!("Request Line: {} {} {}", method, uri, version); | ||||||
|         let headers = try!(Headers::from_raw(&mut stream)); |         let headers = try!(Headers::from_raw(&mut stream)); | ||||||
|   | |||||||
| @@ -14,14 +14,12 @@ use status; | |||||||
| use net::{Fresh, Streaming}; | use net::{Fresh, Streaming}; | ||||||
| use version; | use version; | ||||||
|  |  | ||||||
| pub type InternalWriter<'a> = &'a mut (Writer + 'a); |  | ||||||
|  |  | ||||||
| /// The outgoing half for a Tcp connection, created by a `Server` and given to a `Handler`. | /// The outgoing half for a Tcp connection, created by a `Server` and given to a `Handler`. | ||||||
| pub struct Response<'a, W = Fresh> { | pub struct Response<'a, W = Fresh> { | ||||||
|     /// The HTTP version of this response. |     /// The HTTP version of this response. | ||||||
|     pub version: version::HttpVersion, |     pub version: version::HttpVersion, | ||||||
|     // Stream the Response is writing to, not accessible through UnwrittenResponse |     // Stream the Response is writing to, not accessible through UnwrittenResponse | ||||||
|     body: HttpWriter<InternalWriter<'a>>, |     body: HttpWriter<&'a mut (Writer + 'a)>, | ||||||
|     // The status code for the request. |     // The status code for the request. | ||||||
|     status: status::StatusCode, |     status: status::StatusCode, | ||||||
|     // The outgoing headers on this response. |     // The outgoing headers on this response. | ||||||
| @@ -38,7 +36,7 @@ impl<'a, W> Response<'a, W> { | |||||||
|  |  | ||||||
|     /// Construct a Response from its constituent parts. |     /// Construct a Response from its constituent parts. | ||||||
|     pub fn construct(version: version::HttpVersion, |     pub fn construct(version: version::HttpVersion, | ||||||
|                      body: HttpWriter<InternalWriter<'a>>, |                      body: HttpWriter<&'a mut (Writer + 'a)>, | ||||||
|                      status: status::StatusCode, |                      status: status::StatusCode, | ||||||
|                      headers: header::Headers) -> Response<'a, Fresh> { |                      headers: header::Headers) -> Response<'a, Fresh> { | ||||||
|         Response { |         Response { | ||||||
| @@ -50,7 +48,7 @@ impl<'a, W> Response<'a, W> { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Deconstruct this Response into its constituent parts. |     /// Deconstruct this Response into its constituent parts. | ||||||
|     pub fn deconstruct(self) -> (version::HttpVersion, HttpWriter<InternalWriter<'a>>, |     pub fn deconstruct(self) -> (version::HttpVersion, HttpWriter<&'a mut (Writer + 'a)>, | ||||||
|                                  status::StatusCode, header::Headers) { |                                  status::StatusCode, header::Headers) { | ||||||
|         (self.version, self.body, self.status, self.headers) |         (self.version, self.body, self.status, self.headers) | ||||||
|     } |     } | ||||||
| @@ -58,7 +56,7 @@ impl<'a, W> Response<'a, W> { | |||||||
|  |  | ||||||
| impl<'a> Response<'a, Fresh> { | impl<'a> Response<'a, Fresh> { | ||||||
|     /// Creates a new Response that can be used to write to a network stream. |     /// Creates a new Response that can be used to write to a network stream. | ||||||
|     pub fn new(stream: InternalWriter<'a>) -> Response<'a, Fresh> { |     pub fn new(stream: &'a mut (Writer + 'a)) -> Response<'a, Fresh> { | ||||||
|         Response { |         Response { | ||||||
|             status: status::StatusCode::Ok, |             status: status::StatusCode::Ok, | ||||||
|             version: version::HttpVersion::Http11, |             version: version::HttpVersion::Http11, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user