pub fn start(mut self) -> HttpResult<Request<Streaming>> {
        let mut uri = self.url.serialize_path().unwrap();
        //TODO: this needs a test
        if let Some(ref q) = self.url.query {
            uri.push('?');
            uri.push_str(q[]);
        }

        debug!("writing head: {} {} {}", self.method, uri, self.version);
        try_io!(write!(self.body, "{} {} {}", self.method, uri, self.version))
        try_io!(self.body.write(LINE_ENDING));


        let mut chunked = true;
        let mut len = 0;

        match self.headers.get::<common::ContentLength>() {
            Some(cl) => {
                chunked = false;
                len = cl.len();
            },
            None => ()
        };

        // cant do in match above, thanks borrowck
        if chunked {
            let encodings = match self.headers.get_mut::<common::TransferEncoding>() {
                Some(&common::TransferEncoding(ref mut encodings)) => {
                    //TODO: check if chunked is already in encodings. use HashSet?
                    encodings.push(common::transfer_encoding::Chunked);
                    false
                },
                None => true
            };

            if encodings {
                self.headers.set::<common::TransferEncoding>(
                    common::TransferEncoding(vec![common::transfer_encoding::Chunked]))
            }
        }

        debug!("headers [\n{}]", self.headers);
        try_io!(write!(self.body, "{}", self.headers));

        try_io!(self.body.write(LINE_ENDING));

        let stream = if chunked {
            ChunkedWriter(self.body.unwrap())
        } else {
            SizedWriter(self.body.unwrap(), len)
        };

        Ok(Request {
            method: self.method,
            headers: self.headers,
            url: self.url,
            version: self.version,
            body: stream
        })
    }
/// Consume a Fresh Request, writing the headers and method,
/// returning a Streaming Request.
Consume a Fresh Request, writing the headers and method,
returning a Streaming Request.
Consume a Fresh Request writing the headers and method returning a Streaming Request .
pub fn start(mut self) -> HttpResult<Request<Streaming>> {
        let mut uri = self.url.serialize_path().unwrap();
        //TODO: this needs a test
        if let Some(ref q) = self.url.query {
            uri.push('?');
            uri.push_str(q[]);
        }
        debug!("writing head: {} {} {}", self.method, uri, self.version);
        try_io!(write!(self.body, "{} {} {}", self.method, uri, self.version))
        try_io!(self.body.write(LINE_ENDING));
        let mut chunked = true;
        let mut len = 0;
        match self.headers.get::<common::ContentLength>() {
            Some(cl) => {
                chunked = false;
                len = cl.len();
            },
            None => ()
        };
        // cant do in match above, thanks borrowck
        if chunked {
            let encodings = match self.headers.get_mut::<common::TransferEncoding>() {
                Some(&common::TransferEncoding(ref mut encodings)) => {
                    //TODO: check if chunked is already in encodings. use HashSet?
                    encodings.push(common::transfer_encoding::Chunked);
                    false
                },
                None => true
            };
            if encodings {
                self.headers.set::<common::TransferEncoding>(
                    common::TransferEncoding(vec![common::transfer_encoding::Chunked]))
            }
        }
        debug!("headers [\n{}]", self.headers);
        try_io!(write!(self.body, "{}", self.headers));
        try_io!(self.body.write(LINE_ENDING));
        let stream = if chunked {
            ChunkedWriter(self.body.unwrap())
        } else {
            SizedWriter(self.body.unwrap(), len)
        };
        Ok(Request {
            method: self.method,
            headers: self.headers,
            url: self.url,
            version: self.version,
            body: stream
        })
    }
pub fn start ( mut self ) -> HttpResult < Request < Streaming > > { let mut uri = self . url . serialize_path ( ) . unwrap ( ) ; //TODO: this needs a test if let Some ( ref q ) = self . url . query { uri . push ( '?' ) ; uri . push_str ( q [ ] ) ; } debug ! ( " " self method uri self version ) ; try_io ! ( write ( self body " " self method uri self version ) ) try_io ! ( self body write ( LINE_ENDING ) ) ; let mut chunked = true ; let mut len = 0 ; match self . headers . get :: < common :: ContentLength > ( ) { Some ( cl ) => { chunked = false ; len = cl . len ( ) ; } , None => ( ) } ; // cant do in match above, thanks borrowck if chunked { let encodings = match self . headers . get_mut :: < common :: TransferEncoding > ( ) { Some ( & common :: TransferEncoding ( ref mut encodings ) ) => { //TODO: check if chunked is already in encodings. use HashSet? encodings . push ( common :: transfer_encoding :: Chunked ) ; false } , None => true } ; if encodings { self . headers . set :: < common :: TransferEncoding > ( common :: TransferEncoding ( vec ! [ common transfer_encoding Chunked ] ) ) } } debug ! ( " \n " self headers ) ; try_io ! ( write ( self body " " self headers ) ) ; try_io ! ( self body write ( LINE_ENDING ) ) ; let stream = if chunked { ChunkedWriter ( self . body . unwrap ( ) ) } else { SizedWriter ( self . body . unwrap ( ) , len ) } ; Ok ( Request { method : self . method , headers : self . headers , url : self . url , version : self . version , body : stream } ) }
Consume a Fresh Request, writing the headers and method,
returning a Streaming Request.
Consume a Fresh Request writing the headers and method returning a Streaming Request .
mut self
mut self