pub fn add_header(idata: IData, new_headers: HashMap<String, String>) -> Result<IData, (Decision, Tags, RequestInfo)> {
    let mut dt = idata;
    let secpol = dt.secpol;
    if secpol.content_filter_active {
        let hdrs = &secpol.content_filter_profile.sections.headers;
        if dt.headers.len() + new_headers.len() > hdrs.max_count {
            return Err(early_block(
                dt,
                ContentFilterBlock::TooManyEntries(SectionIdx::Headers).to_action(),
            ));
        }
        for (k, v) in new_headers {
            let kl = k.to_lowercase();
            if kl == "content-length" {
                if let Ok(content_length) = v.parse::<usize>() {
                    if content_length > secpol.content_filter_profile.max_body_size {
                        return Err(early_block(
                            dt,
                            body_too_large(secpol.content_filter_profile.max_body_size, content_length),
                        ));
                    }
                }
            }
            if v.len() > hdrs.max_length {
                return Err(early_block(
                    dt,
                    ContentFilterBlock::EntryTooLarge(SectionIdx::Headers, kl).to_action(),
                ));
            }
            dt.headers.insert(kl, v);
        }
    } else {
        dt.headers.extend(new_headers);
    }
    Ok(dt)
}
/// incrementally add headers, can exit early if there are too many headers, or they are too large
///
/// other properties are not checked at this point (restrict for example), this early check purely exists as an anti DOS measure
incrementally add headers, can exit early if there are too many headers, or they are too large
other properties are not checked at this point (restrict for example), this early check purely exists as an anti DOS measure
incrementally add headers can exit early if there are too many headers or they are too large other properties are not checked at this point ( restrict for example ) this early check purely exists as an anti DOS measure
pub fn add_header(idata: IData, new_headers: HashMap<String, String>) -> Result<IData, (Decision, Tags, RequestInfo)> {
    let mut dt = idata;
    let secpol = dt.secpol;
    if secpol.content_filter_active {
        let hdrs = &secpol.content_filter_profile.sections.headers;
        if dt.headers.len() + new_headers.len() > hdrs.max_count {
            return Err(early_block(
                dt,
                ContentFilterBlock::TooManyEntries(SectionIdx::Headers).to_action(),
            ));
        }
        for (k, v) in new_headers {
            let kl = k.to_lowercase();
            if kl == "content-length" {
                if let Ok(content_length) = v.parse::<usize>() {
                    if content_length > secpol.content_filter_profile.max_body_size {
                        return Err(early_block(
                            dt,
                            body_too_large(secpol.content_filter_profile.max_body_size, content_length),
                        ));
                    }
                }
            }
            if v.len() > hdrs.max_length {
                return Err(early_block(
                    dt,
                    ContentFilterBlock::EntryTooLarge(SectionIdx::Headers, kl).to_action(),
                ));
            }
            dt.headers.insert(kl, v);
        }
    } else {
        dt.headers.extend(new_headers);
    }
    Ok(dt)
}
pub fn add_header ( idata : IData , new_headers : HashMap < String , String > ) -> Result < IData , ( Decision , Tags , RequestInfo ) > { let mut dt = idata ; let secpol = dt . secpol ; if secpol . content_filter_active { let hdrs = & secpol . content_filter_profile . sections . headers ; if dt . headers . len ( ) + new_headers . len ( ) > hdrs . max_count { return Err ( early_block ( dt , ContentFilterBlock :: TooManyEntries ( SectionIdx :: Headers ) . to_action ( ) , ) ) ; } for ( k , v ) in new_headers { let kl = k . to_lowercase ( ) ; if kl == " " { if let Ok ( content_length ) = v . parse :: < usize > ( ) { if content_length > secpol . content_filter_profile . max_body_size { return Err ( early_block ( dt , body_too_large ( secpol . content_filter_profile . max_body_size , content_length ) , ) ) ; } } } if v . len ( ) > hdrs . max_length { return Err ( early_block ( dt , ContentFilterBlock :: EntryTooLarge ( SectionIdx :: Headers , kl ) . to_action ( ) , ) ) ; } dt . headers . insert ( kl , v ) ; } } else { dt . headers . extend ( new_headers ) ; } Ok ( dt ) }
incrementally add headers, can exit early if there are too many headers, or they are too large
other properties are not checked at this point (restrict for example), this early check purely exists as an anti DOS measure
incrementally add headers can exit early if there are too many headers or they are too large other properties are not checked at this point ( restrict for example ) this early check purely exists as an anti DOS measure
idata
IData
new_headers
HashMap<String, String>