From 5f749bb7969c1216af639b38f4654cc1933bb811 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@warmcat.com>
Date: Fri, 29 Apr 2022 10:34:12 +0100
Subject: [PATCH] ss: add get_metadata example

---
 .../client/hello_world-policy/example-policy.json         | 1 +
 .../client/hello_world-policy/hello_world-ss.c            | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/minimal-examples/client/hello_world-policy/example-policy.json b/minimal-examples/client/hello_world-policy/example-policy.json
index b45099d60..ef33e2367 100644
--- a/minimal-examples/client/hello_world-policy/example-policy.json
+++ b/minimal-examples/client/hello_world-policy/example-policy.json
@@ -27,6 +27,7 @@
 				"protocol": "h1",
 				"http_method": "GET",
 				"http_url": "index.html",
+				"metadata": [ { "ctype": "content-type:" } ],
 				"tls": true,
 				"opportunistic": true,
 				"retry": "default",
diff --git a/minimal-examples/client/hello_world-policy/hello_world-ss.c b/minimal-examples/client/hello_world-policy/hello_world-ss.c
index a3be33194..d73a7f1c2 100644
--- a/minimal-examples/client/hello_world-policy/hello_world-ss.c
+++ b/minimal-examples/client/hello_world-policy/hello_world-ss.c
@@ -47,12 +47,20 @@ hello_world_state(void *userobj, void *h_src, lws_ss_constate_t state,
 		  lws_ss_tx_ordinal_t ack)
 {
 	hello_world_t *g = (hello_world_t *)userobj;
+	const char *ct;
+	size_t ctl;
 
 	switch ((int)state) {
 	case LWSSSCS_CREATING: /* start the transaction as soon as we exist */
 		return lws_ss_request_tx(lws_ss_from_user(g));
 
 	case LWSSSCS_QOS_ACK_REMOTE: /* server liked our request */
+
+		if (!lws_ss_get_metadata(g->ss, "ctype", (const void **)&ct, &ctl))
+			lwsl_ss_user(g->ss, "get_metadata ctype '%.*s'", (int)ctl, ct);
+		else
+			lwsl_ss_user(g->ss, "get_metadata ctype missing");
+
 		test_result &= ~1;
 		break;