[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. HTTP_Adaptor: allow keeping an HTTP client connection At the moment the HTTP_Adaptor automatically creates a new connection, performs the HTTP request and closes the connection again. This means the connection lives only for a single request. Let's add some flexibility so that we can perform multiple consecutive requests through the same connection. Change-Id: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Related: SYS#6824 --- M library/HTTP_Adapter.ttcn 1 file changed, 78 insertions(+), 15 deletions(-) Approvals: osmith: Looks good to me, approved Jenkins Builder: Verified diff --git a/library/HTTP_Adapter.ttcn b/library/HTTP_Adapter.ttcn index c78c40a..f408ee4 100644 --- a/library/HTTP_Adapter.ttcn +++ b/library/HTTP_Adapter.ttcn @@ -40,7 +40,7 @@ portnumber := http_port, use_ssl := use_ssl } -template (value) Close ts_HTTP_Close := { client_id := omit }; +template (value) Close ts_HTTP_Close(template (omit) integer client_id := omit) := { client_id := client_id }; /* function to add HeaderLines to a an existing set of HeaderLines. HeaderLines that are already present, are updated. */ function f_overlay_HTTP_Header(HeaderLines hdr, HeaderLines additional_hdr) return template (value) HeaderLines @@ -109,9 +109,10 @@ template (omit) charstring body := omit, integer v_maj := 1, integer v_min := 1, charstring host, -HeaderLines custom_hdr := { }) := { +HeaderLines custom_hdr := { }, +template (omit) integer client_id := omit) := { request := { - client_id := omit, + client_id := client_id, method := method, uri := url, version_major := v_maj, @@ -133,9 +134,10 @@ template (omit) octetstring body := omit, integer v_maj := 1, integer v_min := 1, charstring host, -HeaderLines custom_hdr := { }) := { +HeaderLines custom_hdr := { }, +template (omit) integer client_id := omit) := { request_binary := { - client_id := omit, + client_id := client_id, method := method, uri := url, version_major := v_maj, @@ -175,19 +177,48 @@ function f_http_tx_request(charstring url, charstring method := "GET", template charstring body := omit, template octetstring binary_body := omit, - HeaderLines custom_hdr := { }) + HeaderLines custom_hdr := { }, + float tout := 2.0, + template integer client_id := omit) runs on http_CT { - HTTP.send(ts_HTTP_Connect(g_pars.http_host, g_pars.http_port, g_pars.use_ssl)); - HTTP.receive(Connect_result:?); + var Connect_result rc; + timer T := tout; + var template integer use_client_id := omit; + + /* In case the caller didn't specify a client_id, we will create a new connection. */ + if (istemplatekind(client_id, "omit")) { + HTTP.send(ts_HTTP_Connect(g_pars.http_host, g_pars.http_port, g_pars.use_ssl)); + T.start; + alt { + [] HTTP.receive(Connect_result:?) -> value rc; + [] HTTP.receive { + setverdict(fail, "HTTP connection to client failed"); + self.stop; + } + [] T.timeout { + setverdict(fail, "Timeout waiting for completion of HTTP connection"); + self.stop; + } + } + use_client_id := rc.client_id; + } else { + use_client_id := client_id; + } if (not istemplatekind(body, "omit")) { - HTTP.send(ts_HTTP_Req(url, method, body, host := g_pars.http_host & ":" & int2str(g_pars.http_port), custom_hdr := custom_hdr)); + 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")) { - HTTP.send(ts_HTTP_Req_Bin(url, method, binary_body, host :=
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
Attention is currently required from: dexter, laforge. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?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: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Gerrit-Change-Number: 36646 Gerrit-PatchSet: 2 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: laforge Gerrit-Attention: dexter Gerrit-Comment-Date: Tue, 30 Apr 2024 11:18:53 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
Attention is currently required from: laforge, osmith. dexter has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. Patch Set 2: (1 comment) Commit Message: https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646/comment/8b62e7e7_6c862757 PS1, Line 9: At the moment the HTTP_Adaptor automatically creates a new connection, performs > (if you break lines at 72 characters max - except for error/log messages - it > wraps properly in gerr […] Done -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?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: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Gerrit-Change-Number: 36646 Gerrit-PatchSet: 2 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-Comment-Date: Tue, 30 Apr 2024 10:04:31 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: osmith Gerrit-MessageType: comment
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
Attention is currently required from: laforge, osmith. Hello Jenkins Builder, laforge, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+1 by laforge, Code-Review+1 by osmith, Verified-1 by Jenkins Builder Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. HTTP_Adaptor: allow keeping an HTTP client connection At the moment the HTTP_Adaptor automatically creates a new connection, performs the HTTP request and closes the connection again. This means the connection lives only for a single request. Let's add some flexibility so that we can perform multiple consecutive requests through the same connection. Change-Id: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Related: SYS#6824 --- M library/HTTP_Adapter.ttcn 1 file changed, 78 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/46/36646/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?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: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Gerrit-Change-Number: 36646 Gerrit-PatchSet: 2 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-MessageType: newpatchset
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
Attention is currently required from: dexter. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. Patch Set 1: Code-Review+1 (1 comment) Commit Message: https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646/comment/5b7b5b8f_7fb2668b PS1, Line 9: At the moment the HTTP_Adaptor automatically creates a new connection, performs (if you break lines at 72 characters max - except for error/log messages - it wraps properly in gerrit and makes reviewing easier) -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?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: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Gerrit-Change-Number: 36646 Gerrit-PatchSet: 1 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: dexter Gerrit-Comment-Date: Mon, 29 Apr 2024 07:33:20 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
Attention is currently required from: dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?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: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Gerrit-Change-Number: 36646 Gerrit-PatchSet: 1 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Attention: dexter Gerrit-Comment-Date: Fri, 26 Apr 2024 19:14:57 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. Patch Set 1: (1 comment) File library/HTTP_Adapter.ttcn: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15829): https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646/comment/5c877b87_dbb53125 PS1, Line 188: /* In case the caller didn't specifiy a client_id, we will create a new connection. */ 'specifiy' may be misspelled - perhaps 'specify'? -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?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: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Gerrit-Change-Number: 36646 Gerrit-PatchSet: 1 Gerrit-Owner: dexter Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Thu, 25 Apr 2024 16:05:58 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
[M] Change in osmo-ttcn3-hacks[master]: HTTP_Adaptor: allow keeping an HTTP client connection
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36646?usp=email ) Change subject: HTTP_Adaptor: allow keeping an HTTP client connection .. HTTP_Adaptor: allow keeping an HTTP client connection At the moment the HTTP_Adaptor automatically creates a new connection, performs the HTTP request and closes the connection again. This means the connection lives only for a single request. Let's add some flexibility so that we can perform multiple consecutive requests through the same connection. Change-Id: Ic6994c504143820dde498c1a2bad2ad6a523dd70 Related: SYS#6824 --- M library/HTTP_Adapter.ttcn 1 file changed, 77 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/46/36646/1 diff --git a/library/HTTP_Adapter.ttcn b/library/HTTP_Adapter.ttcn index 1b7605f..411a9a0 100644 --- a/library/HTTP_Adapter.ttcn +++ b/library/HTTP_Adapter.ttcn @@ -40,7 +40,7 @@ portnumber := http_port, use_ssl := use_ssl } -template (value) Close ts_HTTP_Close := { client_id := omit }; +template (value) Close ts_HTTP_Close(template (omit) integer client_id := omit) := { client_id := client_id }; /* function to add HeaderLines to a an existing set of HeaderLines. HeaderLines that are already present, are updated. */ function f_overlay_HTTP_Header(HeaderLines hdr, HeaderLines additional_hdr) return template (value) HeaderLines @@ -109,9 +109,10 @@ template (omit) charstring body := omit, integer v_maj := 1, integer v_min := 1, charstring host, -HeaderLines custom_hdr := { }) := { +HeaderLines custom_hdr := { }, +template (omit) integer client_id := omit) := { request := { - client_id := omit, + client_id := client_id, method := method, uri := url, version_major := v_maj, @@ -133,9 +134,10 @@ template (omit) octetstring body := omit, integer v_maj := 1, integer v_min := 1, charstring host, -HeaderLines custom_hdr := { }) := { +HeaderLines custom_hdr := { }, +template (omit) integer client_id := omit) := { request_binary := { - client_id := omit, + client_id := client_id, method := method, uri := url, version_major := v_maj, @@ -175,19 +177,48 @@ function f_http_tx_request(charstring url, charstring method := "GET", template charstring body := omit, template octetstring binary_body := omit, - HeaderLines custom_hdr := { }) + HeaderLines custom_hdr := { }, + float tout := 2.0, + template integer client_id := omit) runs on http_CT { - HTTP.send(ts_HTTP_Connect(g_pars.http_host, g_pars.http_port, g_pars.use_ssl)); - HTTP.receive(Connect_result:?); + var Connect_result rc; + timer T := tout; + var template integer use_client_id := omit; + + /* In case the caller didn't specifiy a client_id, we will create a new connection. */ + if (istemplatekind(client_id, "omit")) { + HTTP.send(ts_HTTP_Connect(g_pars.http_host, g_pars.http_port, g_pars.use_ssl)); + T.start; + alt { + [] HTTP.receive(Connect_result:?) -> value rc; + [] HTTP.receive { + setverdict(fail, "HTTP connection to client failed"); + self.stop; + } + [] T.timeout { + setverdict(fail, "Timeout waiting for completion of HTTP connection"); + self.stop; + } + } + use_client_id := rc.client_id; + } else { + use_client_id := client_id; + } if (not istemplatekind(body, "omit")) { - HTTP.send(ts_HTTP_Req(url, method, body, host := g_pars.http_host & ":" & int2str(g_pars.http_port), custom_hdr := custom_hdr)); + 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")) { - HTTP.send(ts_HTTP_Req_Bin(url, method, binary_body,