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));
        debug!("Headers: [\n{}]", headers);


        let body = if method == Get || method == Head {
            EmptyReader(stream)
        } else if headers.has::<ContentLength>() {
            match headers.get::<ContentLength>() {
                Some(&ContentLength(len)) => SizedReader(stream, len),
                None => unreachable!()
            }
        } else if headers.has::<TransferEncoding>() {
            todo!("check for Transfer-Encoding: chunked");
            ChunkedReader(stream, None)
        } else {
            EmptyReader(stream)
        };

        Ok(Request {
            remote_addr: addr,
            method: method,
            uri: uri,
            headers: headers,
            version: version,
            body: body
        })
    }
/// Create a new Request, reading the StartLine and Headers so they are
/// immediately useful.
Create a new Request, reading the StartLine and Headers so they are
immediately useful.
Create a new Request reading the StartLine and Headers so they are immediately useful .
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));
        debug!("Headers: [\n{}]", headers);
        let body = if method == Get || method == Head {
            EmptyReader(stream)
        } else if headers.has::<ContentLength>() {
            match headers.get::<ContentLength>() {
                Some(&ContentLength(len)) => SizedReader(stream, len),
                None => unreachable!()
            }
        } else if headers.has::<TransferEncoding>() {
            todo!("check for Transfer-Encoding: chunked");
            ChunkedReader(stream, None)
        } else {
            EmptyReader(stream)
        };
        Ok(Request {
            remote_addr: addr,
            method: method,
            uri: uri,
            headers: headers,
            version: version,
            body: body
        })
    }
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 ! ( " " method uri version ) ; let headers = try ! ( Headers from_raw ( mut stream ) ) ; debug ! ( " \n " headers ) ; let body = if method == Get || method == Head { EmptyReader ( stream ) } else if headers . has :: < ContentLength > ( ) { match headers . get :: < ContentLength > ( ) { Some ( & ContentLength ( len ) ) => SizedReader ( stream , len ) , None => unreachable ! ( ) } } else if headers . has :: < TransferEncoding > ( ) { todo ! ( " " ) ; ChunkedReader ( stream , None ) } else { EmptyReader ( stream ) } ; Ok ( Request { remote_addr : addr , method : method , uri : uri , headers : headers , version : version , body : body } ) }
Create a new Request, reading the StartLine and Headers so they are
immediately useful.
Create a new Request reading the StartLine and Headers so they are immediately useful .
stream
&'a mut (Reader + 'a)
addr
SocketAddr
stream
&'a mut (Reader + 'a)
addr
SocketAddr