[Libwebsockets] "X" headers
Andy Green
andy at warmcat.com
Wed Apr 5 23:02:40 CEST 2017
On April 6, 2017 12:35:18 AM GMT+08:00, Joel Winarske <joel.winarske at gmail.com> wrote:
>Hi Andy,
>
>When I dump all headers at LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
>I'm
>not getting the "X" headers.
>
>Examples:
>
> X-XSS-Protection: 1; mode=block\r\n
> X-Frame-Options: SAMEORIGIN\r\n
>
>Am I doing something wrong, or are "X" headers dropped?
Any header lws doesn't understand is skipped.
You can teach lws new headers, but it has a special procedure to rebuild the lexical anlyzer.
- edit lib/lextable-strings.h and add the new header string at the end before the empty string (after "connect" at the moment)
- add a matching entry in lib/libwebsockets.h, again after LWS_TOKEN_CONNECT at the moment
- cd into ./lib and run this two times:
$ gcc minilex.c -o minilex && ./minilex > lextable.h
Those headers look useful so please send a patch if you add them.
-Andy
>Enumeration code:
>
>do {
>c = lws_token_to_string(n);
>if (c == NULL || *c == 0) {
>n++;
>continue;
>}
>
>len = lws_hdr_total_length(wsi, n);
>if (!len || len > sizeof(buf) - 1) {
>n++;
>continue;
>}
>
>lws_hdr_copy(wsi, buf, sizeof buf, n);
>buf[sizeof(buf) - 1] = '\0';
>fprintf(stderr, " %s %s\n", (char *)c, buf);
>n++;
>} while (c);
>
>
>Thanks,
>Joel
More information about the Libwebsockets
mailing list