Skip to content
LibItsHttp_Functions.ttcn 1.62 KiB
Newer Older
garciay's avatar
garciay committed
module LibItsHttp_Functions {
    
    // LibHttp
    import from LibItsHttp_TypesAndValues all;
    import from LibItsHttp_Pics all;
    
    function f_init_default_headers_list(
                                         out HeaderLines p_headers
    ) {
        p_headers[0] := { c_header_host, { PICS_HEADER_HOST } };
        p_headers[1] := { c_header_content_type, { PICS_HEADER_CONTENT_TYPE } };
        p_headers[2] := { c_header_content_length, { "0" } };
        p_headers[3] := { c_header_connection, { "keep-alive" } };
        p_headers[4] := { c_header_pragma, { "no-cache" } };
        p_headers[5] := { c_header_cache_control, { "no-cache" } };
garciay's avatar
garciay committed
        
    } // End of function f_init_default_headers_list
    
    function f_remove_headears_list(
                                    in charstring_list p_headers_to_remove,
                                    inout HeaderLines p_headers
    ) {
        // Sanity checks
        if (lengthof(p_headers_to_remove) == 0) {
            return;
        } else if (lengthof(p_headers) == 0) {
            return;
        } 
        
        for (var integer v_idx := 0; v_idx < lengthof(p_headers_to_remove); v_idx := v_idx + 1) {
          
            for (var integer v_jdx := 0; v_jdx < lengthof(p_headers); v_jdx := v_jdx + 1) {
                if (p_headers[v_jdx].header_name == p_headers_to_remove[v_idx]) {
                    p_headers[v_jdx].header_value := omit; // NOTE Codec won't encode it
                }
            } // End of 'for' statement
        
        } // End of 'for' statement
    } // End of function f_init_default_headers_list
} // End of module LibItsHttp_Functions