mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ss: add get_metadata example
This commit is contained in:
parent
198a85b53c
commit
5f749bb796
2 changed files with 9 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
|||
"protocol": "h1",
|
||||
"http_method": "GET",
|
||||
"http_url": "index.html",
|
||||
"metadata": [ { "ctype": "content-type:" } ],
|
||||
"tls": true,
|
||||
"opportunistic": true,
|
||||
"retry": "default",
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue