fn decode_header<'buffer>(&mut self, buffer: &mut &'buffer [u8]) -> DecodeResult<()> {
        use self::GenericDecodeResult::*;

        match try_complete!(self.decode_header_name(buffer)) {
            Some(header_name) => {
                if self.builder.headers.values_len() >= self.config.header_max_count() {
                    return Error(DecodeError::TooManyHeaders);
                }

                let rest = &buffer[header_name.len() + 1..];
                let header_value = try_complete!(self.decode_header_value(&rest));
                let header_end_index = header_value.len() + 2;

                let header_name = decoder::trim_header_name(header_name);
                let header_value = decoder::trim_header_value(header_value);

                match HeaderName::try_from(header_name) {
                    Ok(header_name) => match HeaderValue::try_from(header_value) {
                        Ok(header_value) => {
                            self.builder.header(header_name, header_value);
                            *buffer = &rest[header_end_index..];
                            Complete(())
                        }
                        Err(error) => Error(error.into()),
                    },
                    Err(error) => Error(error.into()),
                }
            }
            None => {
                *buffer = &buffer[2..];
                self.state = DecodeState::Body;
                self.content_length = match self.builder.headers.typed_try_get::<ContentLength>() {
                    Ok(Some(content_length)) if *content_length > self.config.body_max_length() => {
                        return Error(DecodeError::BodyTooLong);
                    }
                    Ok(Some(content_length)) => content_length,
                    Ok(None) => ContentLength::default(),
                    Err(_) => {
                        return Error(DecodeError::InvalidContentLength);
                    }
                };
                Complete(())
            }
        }
    }
/// Decodes a full header from the buffer, including the header name and header value that may
/// span multiple lines.
Decodes a full header from the buffer, including the header name and header value that may
span multiple lines.
Decodes a full header from the buffer including the header name and header value that may span multiple lines .
fn decode_header<'buffer>(&mut self, buffer: &mut &'buffer [u8]) -> DecodeResult<()> {
        use self::GenericDecodeResult::*;
        match try_complete!(self.decode_header_name(buffer)) {
            Some(header_name) => {
                if self.builder.headers.values_len() >= self.config.header_max_count() {
                    return Error(DecodeError::TooManyHeaders);
                }
                let rest = &buffer[header_name.len() + 1..];
                let header_value = try_complete!(self.decode_header_value(&rest));
                let header_end_index = header_value.len() + 2;
                let header_name = decoder::trim_header_name(header_name);
                let header_value = decoder::trim_header_value(header_value);
                match HeaderName::try_from(header_name) {
                    Ok(header_name) => match HeaderValue::try_from(header_value) {
                        Ok(header_value) => {
                            self.builder.header(header_name, header_value);
                            *buffer = &rest[header_end_index..];
                            Complete(())
                        }
                        Err(error) => Error(error.into()),
                    },
                    Err(error) => Error(error.into()),
                }
            }
            None => {
                *buffer = &buffer[2..];
                self.state = DecodeState::Body;
                self.content_length = match self.builder.headers.typed_try_get::<ContentLength>() {
                    Ok(Some(content_length)) if *content_length > self.config.body_max_length() => {
                        return Error(DecodeError::BodyTooLong);
                    }
                    Ok(Some(content_length)) => content_length,
                    Ok(None) => ContentLength::default(),
                    Err(_) => {
                        return Error(DecodeError::InvalidContentLength);
                    }
                };
                Complete(())
            }
        }
    }
fn decode_header < ' buffer > ( & mut self , buffer : & mut & ' buffer [ u8 ] ) -> DecodeResult < ( ) > { use self :: GenericDecodeResult :: * ; match try_complete ! ( self decode_header_name ( buffer ) ) { Some ( header_name ) => { if self . builder . headers . values_len ( ) >= self . config . header_max_count ( ) { return Error ( DecodeError :: TooManyHeaders ) ; } let rest = & buffer [ header_name . len ( ) + 1 .. ] ; let header_value = try_complete ! ( self decode_header_value ( rest ) ) ; let header_end_index = header_value . len ( ) + 2 ; let header_name = decoder :: trim_header_name ( header_name ) ; let header_value = decoder :: trim_header_value ( header_value ) ; match HeaderName :: try_from ( header_name ) { Ok ( header_name ) => match HeaderValue :: try_from ( header_value ) { Ok ( header_value ) => { self . builder . header ( header_name , header_value ) ; * buffer = & rest [ header_end_index .. ] ; Complete ( ( ) ) } Err ( error ) => Error ( error . into ( ) ) , } , Err ( error ) => Error ( error . into ( ) ) , } } None => { * buffer = & buffer [ 2 .. ] ; self . state = DecodeState :: Body ; self . content_length = match self . builder . headers . typed_try_get :: < ContentLength > ( ) { Ok ( Some ( content_length ) ) if * content_length > self . config . body_max_length ( ) => { return Error ( DecodeError :: BodyTooLong ) ; } Ok ( Some ( content_length ) ) => content_length , Ok ( None ) => ContentLength :: default ( ) , Err ( _ ) => { return Error ( DecodeError :: InvalidContentLength ) ; } } ; Complete ( ( ) ) } } }
Decodes a full header from the buffer, including the header name and header value that may
span multiple lines.
Decodes a full header from the buffer including the header name and header value that may span multiple lines .
&mut self
buffer
&mut &'buffer [u8]
&mut self
buffer
&mut &'buffer [u8]