Loading ttcn/Http/LibItsHttp_EncdecDeclarations.ttcn 0 → 100644 +11 −0 Original line number Diff line number Diff line module LibItsHttp_EncdecDeclarations { // LibHttp import from LibItsHttp_TypesAndValues all; external function fx_enc_http_message (HttpMessage p) return bitstring with {extension "prototype(convert) encode(HttpCodec)"} external function fx_dec_http_message (inout bitstring b, out HttpMessage p) return integer with {extension "prototype(sliding) decode(HttpCodec)"} } // End of module LibItsHttp_EncdecDeclarations ttcn/Http/LibItsHttp_Functions.ttcn 0 → 100644 +39 −0 Original line number Diff line number Diff line 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_connection, { "keep-alive" } }; p_headers[3] := { c_header_pragma, { "no-cache" } }; p_headers[4] := { 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 module LibItsHttp_Functions ttcn/Http/LibItsHttp_MessageBodyTypes.ttcn 0 → 100644 +13 −0 Original line number Diff line number Diff line module LibItsHttp_MessageBodyTypes { // LibHttp import from LibItsHttp_XmlMessageBodyTypes all; type octetstring MsdBody; type union HttpMessageBody { MsdBody ms_body, XmlBody xml_body } // End of type HttpMessageBody } // End of module LibItsHttp_MessageBodyTypes ttcn/Http/LibItsHttp_Pics.ttcn 0 → 100644 +13 −0 Original line number Diff line number Diff line module LibItsHttp_Pics { /** * @desc */ modulepar charstring PICS_HEADER_HOST := "http://www.lisp.com"; /** * @desc */ modulepar charstring PICS_HEADER_CONTENT_TYPE := "application/held+xml;charset=utf-8"; } // End of module LibItsHttp_Pics ttcn/Http/LibItsHttp_Templates.ttcn +79 −37 Original line number Diff line number Diff line Loading @@ -13,14 +13,10 @@ module LibItsHttp_Templates { // LibHttp import from LibItsHttp_TypesAndValues all; import from LibItsHttp_MessageBodyTypes all; import from LibItsHttp_XmlMessageBodyTypes all; template (value) HeaderLine m_header_line( in template (value) charstring p_header_name, in template (value) charstring_list p_header_value ) := { header_name := p_header_name, header_value := p_header_value } // End of template m_header_line group http_messages { template (value) HttpMessage m_http_request( in template (value) Request p_request Loading @@ -46,10 +42,26 @@ module LibItsHttp_Templates { response := p_response } // End of template mw_http_response } // End of group http_messages group http_headers { template (value) HeaderLine m_header_line( in template (value) charstring p_header_name, in template (value) charstring_list p_header_value ) := { header_name := p_header_name, header_value := p_header_value } // End of template m_header_line } // End of group http_headers group http_requests { template (omit) Request m_http_request_get( in charstring p_uri, in template (value) HeaderLines p_headers, in template (omit) charstring p_body := omit in template (omit) HttpMessageBody p_body := omit ) := { method := "GET", uri := p_uri, Loading @@ -59,4 +71,34 @@ module LibItsHttp_Templates { body := p_body } // End of template m_http_request_get } // End of group http_requests group http_responses { template (present) Response mw_http_response_ok( template (present) HttpMessageBody p_body := ?, template (present) HeaderLines p_header := ? ) := { version_major := 1, version_minor := 1, statuscode := 200, statustext := "OK", header := p_header, body := p_body } // End of template mw_http_response_ok } // End of group http_responses template (value) HttpMessageBody m_http_message_body_xml( in template (value) XmlBody p_xml_body ) := { xml_body := p_xml_body } // End of template m_http_message_body_xml template (present) HttpMessageBody mw_http_message_body_xml( template (present) XmlBody p_xml_body := ? ) := { xml_body := p_xml_body } // End of template mw_http_message_body_xml } // End of module LibItsHttp_Templates Loading
ttcn/Http/LibItsHttp_EncdecDeclarations.ttcn 0 → 100644 +11 −0 Original line number Diff line number Diff line module LibItsHttp_EncdecDeclarations { // LibHttp import from LibItsHttp_TypesAndValues all; external function fx_enc_http_message (HttpMessage p) return bitstring with {extension "prototype(convert) encode(HttpCodec)"} external function fx_dec_http_message (inout bitstring b, out HttpMessage p) return integer with {extension "prototype(sliding) decode(HttpCodec)"} } // End of module LibItsHttp_EncdecDeclarations
ttcn/Http/LibItsHttp_Functions.ttcn 0 → 100644 +39 −0 Original line number Diff line number Diff line 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_connection, { "keep-alive" } }; p_headers[3] := { c_header_pragma, { "no-cache" } }; p_headers[4] := { 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 module LibItsHttp_Functions
ttcn/Http/LibItsHttp_MessageBodyTypes.ttcn 0 → 100644 +13 −0 Original line number Diff line number Diff line module LibItsHttp_MessageBodyTypes { // LibHttp import from LibItsHttp_XmlMessageBodyTypes all; type octetstring MsdBody; type union HttpMessageBody { MsdBody ms_body, XmlBody xml_body } // End of type HttpMessageBody } // End of module LibItsHttp_MessageBodyTypes
ttcn/Http/LibItsHttp_Pics.ttcn 0 → 100644 +13 −0 Original line number Diff line number Diff line module LibItsHttp_Pics { /** * @desc */ modulepar charstring PICS_HEADER_HOST := "http://www.lisp.com"; /** * @desc */ modulepar charstring PICS_HEADER_CONTENT_TYPE := "application/held+xml;charset=utf-8"; } // End of module LibItsHttp_Pics
ttcn/Http/LibItsHttp_Templates.ttcn +79 −37 Original line number Diff line number Diff line Loading @@ -13,14 +13,10 @@ module LibItsHttp_Templates { // LibHttp import from LibItsHttp_TypesAndValues all; import from LibItsHttp_MessageBodyTypes all; import from LibItsHttp_XmlMessageBodyTypes all; template (value) HeaderLine m_header_line( in template (value) charstring p_header_name, in template (value) charstring_list p_header_value ) := { header_name := p_header_name, header_value := p_header_value } // End of template m_header_line group http_messages { template (value) HttpMessage m_http_request( in template (value) Request p_request Loading @@ -46,10 +42,26 @@ module LibItsHttp_Templates { response := p_response } // End of template mw_http_response } // End of group http_messages group http_headers { template (value) HeaderLine m_header_line( in template (value) charstring p_header_name, in template (value) charstring_list p_header_value ) := { header_name := p_header_name, header_value := p_header_value } // End of template m_header_line } // End of group http_headers group http_requests { template (omit) Request m_http_request_get( in charstring p_uri, in template (value) HeaderLines p_headers, in template (omit) charstring p_body := omit in template (omit) HttpMessageBody p_body := omit ) := { method := "GET", uri := p_uri, Loading @@ -59,4 +71,34 @@ module LibItsHttp_Templates { body := p_body } // End of template m_http_request_get } // End of group http_requests group http_responses { template (present) Response mw_http_response_ok( template (present) HttpMessageBody p_body := ?, template (present) HeaderLines p_header := ? ) := { version_major := 1, version_minor := 1, statuscode := 200, statustext := "OK", header := p_header, body := p_body } // End of template mw_http_response_ok } // End of group http_responses template (value) HttpMessageBody m_http_message_body_xml( in template (value) XmlBody p_xml_body ) := { xml_body := p_xml_body } // End of template m_http_message_body_xml template (present) HttpMessageBody mw_http_message_body_xml( template (present) XmlBody p_xml_body := ? ) := { xml_body := p_xml_body } // End of template mw_http_message_body_xml } // End of module LibItsHttp_Templates