[Libwebsockets] subprotocol parsing issue (is dot a delimiter?)
Dave Horton
daveh at beachdognet.com
Mon May 20 19:05:55 CEST 2019
Yes. If I change these lines, at or around line 327 at roles/server-ws.c from this:
lws_tokenize_init(&ts, buf, LWS_TOKENIZE_F_COMMA_SEP_LIST |
LWS_TOKENIZE_F_MINUS_NONTERM |
LWS_TOKENIZE_F_RFC7230_DELIMS);
to this:
lws_tokenize_init(&ts, buf, LWS_TOKENIZE_F_COMMA_SEP_LIST |
LWS_TOKENIZE_F_MINUS_NONTERM |
LWS_TOKENIZE_F_DOT_NONTERM
LWS_TOKENIZE_F_RFC7230_DELIMS);
and rebuild libwebsockets, then rebuild my web server, then it works.
On May 20, 2019, at 11:17 AM, Andy Green <andy at warmcat.com> wrote:
On May 20, 2019 7:55:00 AM PDT, Dave Horton <daveh at beachdognet.com> wrote:
> I’m sure this is an issue / misunderstanding on my side, but my client
> is using a subprotocol named “audiostream.drachtio.org”, ie my upgrade
> request looks like this
>
> GET / HTTP/1.1
> Pragma: no-cache
> Cache-Control: no-cache
> Host: 127.0.0.1
> Origin: http://127.0.0.1
> Upgrade: websocket
> Connection: close, Upgrade
> Sec-WebSocket-Key: O/QI+xJO4BEDFQKSNYQyhA==
> Sec-WebSocket-Protocol: audiostream.drachtio.org
> Sec-WebSocket-Version: 13
>
>
> However, my lws server is parsing that as “audiostream”, i.e. it is
> taking a dot (.) as a delimiter. I’ve stepped through the code in gdb
> and I can see that it is doing this. At the end of lws_tokenize it is
> returning this
>
> (gdb) n
> 3324 return LWS_TOKZE_TOKEN;
> (gdb) p *ts
> $19 = {start = 0x7fffffffdbcb ".drachtio.org", token = 0x7fffffffdbc0
> "audiostream.drachtio.org", len = 13, token_len = 11, flags = 13, delim
> = 1}
>
> I thought using dot domain separated subprotocols was a recommended
> practice. What am I doing wrong? This is on the v3.1.0 tag BTW
It should be okay. Does it help if you add this flag to the tokenizer init for the code calling that?
https://libwebsockets.org/git/libwebsockets/tree/include/libwebsockets/lws-tokenize.h?h=v3.1-stable#n34
-Andy
> Dave
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
More information about the Libwebsockets
mailing list