[Libwebsockets] Custom Header in websockets

Andy Green andy at warmcat.com
Fri Jun 3 14:38:49 CEST 2016



On 06/03/2016 08:31 PM, techi eth wrote:
> If i have some info in custom header then while calling lws_hdr_copy()
> function what will be the token index value.
>
> Ex : Header Key is TestLibWebsockets then what i need to pass while
> calling lws_hdr_copy.

It's not so simple... lws has a set of headers it understands and makes 
arrangements to decode.

https://github.com/warmcat/libwebsockets/blob/master/lib/lextable-strings.h

headers outside that set (but it's a pretty comprehensive set) are ignored.

If you want to have lws parse a "custom header" (but is it really a good 
idea?) then you need to add to that list - at the end, before "" - and 
adapt this enum accordingly to match

https://github.com/warmcat/libwebsockets/blob/master/lib/libwebsockets.h#L603

After that, build and run minilex

https://github.com/warmcat/libwebsockets/blob/master/lib/minilex.c#L10

and recook the library.

the answer to your question "what token index value" should be 
self-evident now.

-Andy


> Thanks
>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets
>



More information about the Libwebsockets mailing list