Skip to content

rustup #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(macro_rules, phase, default_type_params, if_let, slicing_syntax,
tuple_indexing, globs)]
#![feature(macro_rules, phase, default_type_params, slicing_syntax, globs)]
#![deny(missing_docs)]
#![deny(warnings)]
#![experimental]
Expand Down
6 changes: 2 additions & 4 deletions src/server/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use http::HttpReader;
use http::HttpReader::{SizedReader, ChunkedReader, EmptyReader};
use uri::RequestUri;

pub type InternalReader<'a> = &'a mut (Reader + 'a);

/// A request bundles several parts of an incoming `NetworkStream`, given to a `Handler`.
pub struct Request<'a> {
/// The IP address of the remote connection.
Expand All @@ -29,15 +27,15 @@ pub struct Request<'a> {
pub uri: RequestUri,
/// The version of HTTP for this request.
pub version: HttpVersion,
body: HttpReader<InternalReader<'a>>
body: HttpReader<&'a mut (Reader + 'a)>
}


impl<'a> Request<'a> {

/// Create a new Request, reading the StartLine and Headers so they are
/// 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));
debug!("Request Line: {} {} {}", method, uri, version);
let headers = try!(Headers::from_raw(&mut stream));
Expand Down
10 changes: 4 additions & 6 deletions src/server/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ use status;
use net::{Fresh, Streaming};
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`.
pub struct Response<'a, W = Fresh> {
/// The HTTP version of this response.
pub version: version::HttpVersion,
// 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.
status: status::StatusCode,
// The outgoing headers on this response.
Expand All @@ -38,7 +36,7 @@ impl<'a, W> Response<'a, W> {

/// Construct a Response from its constituent parts.
pub fn construct(version: version::HttpVersion,
body: HttpWriter<InternalWriter<'a>>,
body: HttpWriter<&'a mut (Writer + 'a)>,
status: status::StatusCode,
headers: header::Headers) -> Response<'a, Fresh> {
Response {
Expand All @@ -50,15 +48,15 @@ impl<'a, W> Response<'a, W> {
}

/// 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) {
(self.version, self.body, self.status, self.headers)
}
}

impl<'a> Response<'a, Fresh> {
/// 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 {
status: status::StatusCode::Ok,
version: version::HttpVersion::Http11,
Expand Down