/// every header returned by the Worker is prefixed
/// and headers without a prefix are specific to the preview service
/// here we parse those headers and construct a new header map
///
/// discard headers without that prefix
/// strip the prefix from real Workers headers
every header returned by the Worker is prefixed
and headers without a prefix are specific to the preview service
here we parse those headers and construct a new header map

discard headers without that prefix
strip the prefix from real Workers headers
every header returned by the Worker is prefixed and headers without a prefix are specific to the preview service here we parse those headers and construct a new header map discard headers without that prefix strip the prefix from real Workers headers
fn strip_response_headers_prefix(parts: &mut ResponseParts) -> Result<()> {
    let mut headers = HeaderMap::new();
    for header in &parts.headers {
        let (name, value) = header;
        let name = name.as_str();
        if let Some(header_name) = name.strip_prefix(HEADER_PREFIX) {
            let header_name = HeaderName::from_bytes(header_name.as_bytes())?;
            headers.append(header_name, value.clone());
        }
    }
    parts.headers = headers;
    Ok(())
}
fn strip_response_headers_prefix ( parts : & mut ResponseParts ) -> Result < ( ) > { let mut headers = HeaderMap :: new ( ) ; for header in & parts . headers { let ( name , value ) = header ; let name = name . as_str ( ) ; if let Some ( header_name ) = name . strip_prefix ( HEADER_PREFIX ) { let header_name = HeaderName :: from_bytes ( header_name . as_bytes ( ) ) ? ; headers . append ( header_name , value . clone ( ) ) ; } } parts . headers = headers ; Ok ( ( ) ) }
every header returned by the Worker is prefixed
and headers without a prefix are specific to the preview service
here we parse those headers and construct a new header map
every header returned by the Worker is prefixed and headers without a prefix are specific to the preview service here we parse those headers and construct a new header map
parts
&mut ResponseParts