HTTP_Adapter: fix request sending in f_http_tx_request
The function f_http_tx_request has two parameters to spcifiy the body
part of the HTTP request (body and binary_body). The function only
sends a request when either body or binary_body is populated, but not
when none of the two is populated. This means requests without body
part (e.g. a GET request) can not be sent.
There is also no proper interlocking between body and binary_body. We
should make sure that this situation does not occur.
Related: SYS#6824
Change-Id: I258ee6209c35d0601f5a4d82423d2f5c6fbb03cc
diff --git a/library/HTTP_Adapter.ttcn b/library/HTTP_Adapter.ttcn
index f408ee4..97233e5 100644
--- a/library/HTTP_Adapter.ttcn
+++ b/library/HTTP_Adapter.ttcn
@@ -205,13 +205,21 @@
use_client_id := client_id;
}
- if (not istemplatekind(body, "omit")) {
+ if (not istemplatekind(body, "omit") and istemplatekind(binary_body, "omit")) {
+ /* HTTP message with ASCII content */
HTTP.send(ts_HTTP_Req(url, method, body, host := g_pars.http_host & ":" & int2str(g_pars.http_port),
custom_hdr := custom_hdr, client_id := use_client_id));
- } else if (not istemplatekind(binary_body, "omit")) {
+ } else if (not istemplatekind(binary_body, "omit") and istemplatekind(body, "omit")) {
+ /* HTTP message with binary content */
HTTP.send(ts_HTTP_Req_Bin(url, method, binary_body,
host := g_pars.http_host & ":" & int2str(g_pars.http_port),
custom_hdr := custom_hdr, client_id := use_client_id));
+ } else if (istemplatekind(binary_body, "omit") and istemplatekind(body, "omit")) {
+ /* HTTP message without content (e.g. a GET request) */
+ HTTP.send(ts_HTTP_Req(url, method, host := g_pars.http_host & ":" & int2str(g_pars.http_port),
+ custom_hdr := custom_hdr, client_id := use_client_id));
+ } else {
+ setverdict(fail, "either binary_body or body must be used (a request can contain either ASCII data or binary data, not both!");
}
}