HTTP_Adapter: add HOST field to header lines.
In HTTP 1.1 (this is what the HTTP_Adapter uses), the Host header field
is mandatory, see also: RFC 2616, section 14.23.
Related: SYS#6824
Change-Id: Id4b2220da4b2b5fbe74cdc2776cf66d6b34ddbcf
diff --git a/library/HTTP_Adapter.ttcn b/library/HTTP_Adapter.ttcn
index a957fdd..0885f05 100644
--- a/library/HTTP_Adapter.ttcn
+++ b/library/HTTP_Adapter.ttcn
@@ -37,7 +37,8 @@
}
template (value) Close ts_HTTP_Close := { client_id := omit };
-template (value) HeaderLines ts_HTTP_Header(charstring body) := {
+template (value) HeaderLines ts_HTTP_Header(charstring body, charstring host) := {
+ { header_name := "Host", header_value := host },
{ header_name := "Content-Type", header_value := "application/json" },
{ header_name := "Content-Length", header_value := int2str(lengthof(body)) }
}
@@ -45,14 +46,15 @@
template (value) HTTPMessage ts_HTTP_Req(charstring url,
charstring method := "GET",
charstring body := "",
- integer v_maj := 1, integer v_min := 1) := {
+ integer v_maj := 1, integer v_min := 1,
+ charstring host) := {
request := {
client_id := omit,
method := method,
uri := url,
version_major := v_maj,
version_minor := v_min,
- header := ts_HTTP_Header(body),
+ header := valueof(ts_HTTP_Header(body, host)),
body := body
}
}
@@ -75,7 +77,7 @@
runs on http_CT {
HTTP.send(ts_HTTP_Connect(g_http_host, g_http_port));
HTTP.receive(Connect_result:?);
- HTTP.send(ts_HTTP_Req(url, method, body));
+ HTTP.send(ts_HTTP_Req(url, method, body, host := g_http_host & ":" & int2str(g_http_port)));
}
function f_http_rx_response(template HTTPMessage exp := tr_HTTP_Resp2xx, float tout := 2.0)