laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36505?usp=email )

 (

5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: HTTP_Adapter: allow body to be "omit"
......................................................................

HTTP_Adapter: allow body to be "omit"

In HTTP not all requests have a body. At the moment we describe a
missing body with body := "". This is not 100% correct since the rest of
the code interprets this as a present body with zero length and will put
a content_length = 0 header line into the HTTP header, even in the GET
request. This will most likely be ignored by any HTTP server, but it is
still not 100% spec compliant.

Related: SYS#6824
Change-Id: Ifedc8c2a590835663d1ba0b08b1fe4d54bdd0fff
---
M library/HTTP_Adapter.ttcn
1 file changed, 29 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved




diff --git a/library/HTTP_Adapter.ttcn b/library/HTTP_Adapter.ttcn
index b302a80..9ad1e4a 100644
--- a/library/HTTP_Adapter.ttcn
+++ b/library/HTTP_Adapter.ttcn
@@ -84,9 +84,16 @@
        return f_overlay_HTTP_Header(hdr, custom_hdr);
 }

+function f_ts_body_or_empty(template (omit) charstring body) return template 
(value) charstring {
+       if (istemplatekind(body, "omit")) {
+               return "";
+       }
+       return body;
+}
+
 template (value) HTTPMessage ts_HTTP_Req(charstring url,
                                         charstring method := "GET",
-                                        charstring body := "",
+                                        template (omit) charstring body := 
omit,
                                         integer v_maj := 1, integer v_min := 1,
                                         charstring host,
                                         HeaderLines custom_hdr := { }) := {
@@ -96,8 +103,8 @@
                uri := url,
                version_major := v_maj,
                version_minor := v_min,
-               header := valueof(f_ts_HTTP_Header(body, host, custom_hdr)),
-               body := body
+               header := f_ts_HTTP_Header(body, host, custom_hdr),
+               body := f_ts_body_or_empty(body)
        }
 }

@@ -115,7 +122,7 @@

 template HTTPMessage tr_HTTP_Resp2xx := tr_HTTP_Resp((200..299));

-function f_http_tx_request(charstring url, charstring method := "GET", 
charstring body := "",
+function f_http_tx_request(charstring url, charstring method := "GET", 
template charstring body := omit,
                           HeaderLines custom_hdr := { })
 runs on http_CT {
        HTTP.send(ts_HTTP_Connect(g_http_host, g_http_port));
@@ -146,7 +153,7 @@

 /* run a HTTP request and return the response */
 function f_http_transact(charstring url, charstring method := "GET",
-                        charstring body := "", template HTTPMessage exp := 
tr_HTTP_Resp2xx,
+                        template (omit) charstring body := omit, template 
HTTPMessage exp := tr_HTTP_Resp2xx,
                         float tout := 2.0, HeaderLines custom_hdr := { })
 runs on http_CT return HTTPMessage {
        f_http_tx_request(url, method, body, custom_hdr);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36505?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: Ifedc8c2a590835663d1ba0b08b1fe4d54bdd0fff
Gerrit-Change-Number: 36505
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to