aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-02-22 09:16:21 +0100
committerlaforge <laforge@osmocom.org>2021-02-22 10:41:29 +0000
commit205b537f6f2daf0fc3848a0e19fdd3518139e4cd (patch)
tree9084fa6a2cd1ac1cceba1358c796336c5571cc9f
parentad9d8366f8fcb39d61b5e9f2286550a4a013a63a (diff)
HTTP_Adapter: split into f_http_tx_request() / f_http_rx_response()
There are some use cases in which we don't want a blocking wait for the full HTTP request to complete. Let's split it up in two parts, and make the existing f_http_transact() a wrapper around them. Also, enable the generation of the Connect_result primitive to detect connection failures. Change-Id: I5c7575c0b58c3606d25d8f8cfccd47cfb7a8c400
-rw-r--r--library/HTTP_Adapter.ttcn25
-rw-r--r--remsim/REMSIM_Tests.default2
2 files changed, 18 insertions, 9 deletions
diff --git a/library/HTTP_Adapter.ttcn b/library/HTTP_Adapter.ttcn
index 03de1f3b..a957fdd9 100644
--- a/library/HTTP_Adapter.ttcn
+++ b/library/HTTP_Adapter.ttcn
@@ -71,17 +71,17 @@ template HTTPMessage tr_HTTP_Resp(template integer sts := ?) := {
template HTTPMessage tr_HTTP_Resp2xx := tr_HTTP_Resp((200..299));
-/* 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,
- float tout := 2.0)
+function f_http_tx_request(charstring url, charstring method := "GET", charstring body := "")
+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));
+}
+
+function f_http_rx_response(template HTTPMessage exp := tr_HTTP_Resp2xx, float tout := 2.0)
runs on http_CT return HTTPMessage {
var HTTPMessage resp;
timer T := tout;
-
- HTTP.send(ts_HTTP_Connect(g_http_host, g_http_port));
- //HTTP.receive(Connect_result:?);
- HTTP.send(ts_HTTP_Req(url, method, body));
T.start;
alt {
[] HTTP.receive(exp) -> value resp {
@@ -99,4 +99,13 @@ runs on http_CT return HTTPMessage {
return resp;
}
+/* 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,
+ float tout := 2.0)
+runs on http_CT return HTTPMessage {
+ f_http_tx_request(url, method, body);
+ return f_http_rx_response(exp, tout);
+}
+
}
diff --git a/remsim/REMSIM_Tests.default b/remsim/REMSIM_Tests.default
index 7a415555..3059a8d5 100644
--- a/remsim/REMSIM_Tests.default
+++ b/remsim/REMSIM_Tests.default
@@ -1,3 +1,3 @@
[TESTPORT_PARAMETERS]
system.HTTP.http_debugging := "yes"
-system.HTTP.use_notification_ASPs := "no"
+system.HTTP.use_notification_ASPs := "yes"