```
"ws-protocols": [{
- "warmcat,timezoom": {
+ "warmcat-timezoom": {
"status": "ok"
}
}]
LWS_CALLBACK_PROTOCOL_INIT (@in is a pointer to a linked list of struct lws_protocol_vhost_options
containing the name and value pointers).
+To indicate that a protocol should be used when no Protocol: header is sent
+by the client, you can use "default": "1"
+
+```
+ "ws-protocols": [{
+ "warmcat-timezoom": {
+ "status": "ok",
+ "default": "1"
+ }
+ }]
+
+```
+
Other vhost options
-------------------
.woff application/font-woff
.xml application/xml
-
+5) Allow per-vhost setting of which protocol should get used
+when the protocol: header is not sent by the client
v2.0.0
lws_protocol_init(struct lws_context *context)
{
struct lws_vhost *vh = context->vhost_list;
- const struct lws_protocol_vhost_options *pvo;
+ const struct lws_protocol_vhost_options *pvo, *pvo1;
struct lws wsi;
int n;
memset(&wsi, 0, sizeof(wsi));
wsi.context = context;
+ lwsl_notice("%s\n", __func__);
+
while (vh) {
wsi.vhost = vh;
pvo = lws_vhost_protocol_options(vh,
vh->protocols[n].name);
- if (pvo)
+ if (pvo) {
/*
* linked list of options specific to
* vh + protocol
*/
- pvo = pvo->options;
+ pvo1 = pvo;
+ pvo = pvo1->options;
+
+ while (pvo) {
+ lwsl_notice(" vh %s prot %s opt %s\n",
+ vh->name,
+ vh->protocols[n].name,
+ pvo->name);
+
+ if (!strcmp(pvo->name, "default")) {
+ lwsl_notice("Setting default "
+ "protocol for vh %s to %s\n",
+ vh->name,
+ vh->protocols[n].name);
+ vh->default_protocol_index = n;
+ }
+ pvo = pvo->next;
+ }
+
+ pvo = pvo1->options;
+ }
/*
* inform all the protocols that they are doing their one-time
int allow_non_ssl_on_ssl_port;
unsigned int user_supplied_ssl_ctx:1;
#endif
+ unsigned char default_protocol_index;
};
/*
/*
* some clients only have one protocol and
* do not send the protocol list header...
- * allow it and match to protocol 0
+ * allow it and match to the vhost's default
+ * protocol (which itself defaults to zero)
*/
- lwsl_info("defaulting to prot 0 handler\n");
+ lwsl_info("defaulting to prot handler %d\n",
+ wsi->vhost->default_protocol_index);
n = 0;
- wsi->protocol = &wsi->vhost->protocols[0];
+ wsi->protocol = &wsi->vhost->protocols[
+ (int)wsi->vhost->default_protocol_index];
}
/* allocate wsi->user storage */