dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36710?usp=email )


Change subject: HTTP_Adapter: fix request sending in f_http_tx_request
......................................................................

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
---
M library/HTTP_Adapter.ttcn
1 file changed, 29 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/10/36710/1

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!");
        }
 }


--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36710?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I258ee6209c35d0601f5a4d82423d2f5c6fbb03cc
Gerrit-Change-Number: 36710
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to