pub fn parse_header(src: &str) -> Result<HeaderMap, httparse::Error> {
    let mut headers = [httparse::EMPTY_HEADER; 1];
    let header = format!("{}\n", src);
    httparse::parse_headers(header.as_bytes(), &mut headers)?;

    let mut header_map = HeaderMap::new();
    if let Some(h) = headers.first() {
        if h.name != httparse::EMPTY_HEADER.name {
            header_map.insert(
                HeaderName::from_bytes(h.name.as_bytes()).unwrap(),
                HeaderValue::from_bytes(h.value).unwrap(),
            );
        }
    }

    Ok(header_map)
}
/// Custom header parser (allow multiple headers input)
Custom header parser (allow multiple headers input)
Custom header parser ( allow multiple headers input )
pub fn parse_header(src: &str) -> Result<HeaderMap, httparse::Error> {
    let mut headers = [httparse::EMPTY_HEADER; 1];
    let header = format!("{}\n", src);
    httparse::parse_headers(header.as_bytes(), &mut headers)?;
    let mut header_map = HeaderMap::new();
    if let Some(h) = headers.first() {
        if h.name != httparse::EMPTY_HEADER.name {
            header_map.insert(
                HeaderName::from_bytes(h.name.as_bytes()).unwrap(),
                HeaderValue::from_bytes(h.value).unwrap(),
            );
        }
    }
    Ok(header_map)
}
pub fn parse_header ( src : & str ) -> Result < HeaderMap , httparse :: Error > { let mut headers = [ httparse :: EMPTY_HEADER ; 1 ] ; let header = format ! ( " \n " src ) ; httparse :: parse_headers ( header . as_bytes ( ) , & mut headers ) ? ; let mut header_map = HeaderMap :: new ( ) ; if let Some ( h ) = headers . first ( ) { if h . name != httparse :: EMPTY_HEADER . name { header_map . insert ( HeaderName :: from_bytes ( h . name . as_bytes ( ) ) . unwrap ( ) , HeaderValue :: from_bytes ( h . value ) . unwrap ( ) , ) ; } } Ok ( header_map ) }
Custom header parser (allow multiple headers input)
Custom header parser ( allow multiple headers input )
src
&str
src
&str