pub fn parse(&mut self, buf: &'b [u8]) -> Result<usize> {
        let orig_len = buf.len();
        let mut bytes = Bytes::new(buf);
        complete!(skip_empty_lines(&mut bytes));
        self.method = Some(complete!(parse_token(&mut bytes)));
        self.path = Some(complete!(parse_token(&mut bytes)));
        self.version = Some(complete!(parse_version(&mut bytes)));
        newline!(bytes);

        let len = orig_len - bytes.len();
        let headers_len = complete!(parse_headers_iter(&mut self.headers, &mut bytes));
        match self.headers.iter().find(|&h| h.name == "Encapsulated") {
            Some(h) => {
                self.encapsulated_sections = Some(parse_encapsulated(h.value, &buf[len+headers_len..buf.len()]));
                Ok(Status::Complete(orig_len + len - len + headers_len - headers_len))
            },
            None => {
                match self.method {
                  Some("OPTIONS") => Ok(Status::Complete(orig_len)),
                  _ =>  Err(Error::MissingEncapsulated)
                }
            }
        }

    }
/// Try to parse a buffer of bytes into the Request.
Try to parse a buffer of bytes into the Request.
Try to parse a buffer of bytes into the Request .
pub fn parse(&mut self, buf: &'b [u8]) -> Result<usize> {
        let orig_len = buf.len();
        let mut bytes = Bytes::new(buf);
        complete!(skip_empty_lines(&mut bytes));
        self.method = Some(complete!(parse_token(&mut bytes)));
        self.path = Some(complete!(parse_token(&mut bytes)));
        self.version = Some(complete!(parse_version(&mut bytes)));
        newline!(bytes);
        let len = orig_len - bytes.len();
        let headers_len = complete!(parse_headers_iter(&mut self.headers, &mut bytes));
        match self.headers.iter().find(|&h| h.name == "Encapsulated") {
            Some(h) => {
                self.encapsulated_sections = Some(parse_encapsulated(h.value, &buf[len+headers_len..buf.len()]));
                Ok(Status::Complete(orig_len + len - len + headers_len - headers_len))
            },
            None => {
                match self.method {
                  Some("OPTIONS") => Ok(Status::Complete(orig_len)),
                  _ =>  Err(Error::MissingEncapsulated)
                }
            }
        }
    }
pub fn parse ( & mut self , buf : & ' b [ u8 ] ) -> Result < usize > { let orig_len = buf . len ( ) ; let mut bytes = Bytes :: new ( buf ) ; complete ! ( skip_empty_lines ( mut bytes ) ) ; self . method = Some ( complete ! ( parse_token ( mut bytes ) ) ) ; self . path = Some ( complete ! ( parse_token ( mut bytes ) ) ) ; self . version = Some ( complete ! ( parse_version ( mut bytes ) ) ) ; newline ! ( bytes ) ; let len = orig_len - bytes . len ( ) ; let headers_len = complete ! ( parse_headers_iter ( mut self headers mut bytes ) ) ; match self . headers . iter ( ) . find ( | & h | h . name == " " ) { Some ( h ) => { self . encapsulated_sections = Some ( parse_encapsulated ( h . value , & buf [ len + headers_len .. buf . len ( ) ] ) ) ; Ok ( Status :: Complete ( orig_len + len - len + headers_len - headers_len ) ) } , None => { match self . method { Some ( " " ) => Ok ( Status :: Complete ( orig_len ) ) , _ => Err ( Error :: MissingEncapsulated ) } } } }
Try to parse a buffer of bytes into the Request.
Try to parse a buffer of bytes into the Request .
&mut self
buf
&'b [u8]
&mut self
buf
&'b [u8]