LibItsHttp_Functions.ttcn 2.86 KB
Newer Older
garciay's avatar
garciay committed
1
2
module LibItsHttp_Functions {
    
Yann Garcia's avatar
Yann Garcia committed
3
4
5
6
7
    // LibCommon
    import from LibCommon_Time all;
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
    
garciay's avatar
garciay committed
8
9
10
    // LibHttp
    import from LibItsHttp_TypesAndValues all;
    import from LibItsHttp_Pics all;
Yann Garcia's avatar
Yann Garcia committed
11
    import from LibItsHttp_TestSystem all;
garciay's avatar
garciay committed
12
    
Yann Garcia's avatar
Yann Garcia committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    group http_preambles {
      
      /**
       * @desc    Setups default configuration   
       * @param   p_certificateId The certificate identifier the TA shall use in case of secured IUT
       */
      function f_cfUp(
                      in charstring p_certificateId
      ) runs on HttpComponent /* TITAN TODO: system HttpTestAdapter */ {
          
          map(self:httpPort, system:httpPort);
          f_connect4SelfOrClientSync();
          
      } // End of function f_cfUp
      
    } // End of group http_preambles 
garciay's avatar
garciay committed
29
    
Yann Garcia's avatar
Yann Garcia committed
30
31
32
33
34
35
    group http_postambles {
      
      /**
       * @desc    Deletes default configuration 
       */
      function f_cfDown() runs on HttpComponent /* TITAN TODO: system HttpTestAdapter */ {
garciay's avatar
garciay committed
36
          
Yann Garcia's avatar
Yann Garcia committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
          unmap(self:httpPort, system:httpPort);
          f_disconnect4SelfOrClientSync();
          
      } // End of function f_cfDown
      
    } // End of group http_postambles 
    
    group http_headers {
      
      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" } };
          
      } // 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 group http_headers
    
garciay's avatar
garciay committed
82
} // End of module LibItsHttp_Functions