[Libwebsockets] libwebsockets HTTP mode lacks LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION
"Andy Green (林安廸)"
andy at warmcat.com
Sat Nov 9 05:08:28 CET 2013
On 09/11/13 08:28, the mail apparently from "Andy Green (林安廸)" included:
> On 09/11/13 02:40, the mail apparently from Johan Lindh included:
>> Not having access to any client headers except the URI is unacceptable
> You don't have to accept it ^^
>> in LWS_CALLBACK_HTTP, and current HEAD in git does not issue
>> WS_CALLBACK_FILTER_PROTOCOL_CONNECTION for HTTP connections.
> I can see it would be useful to do something, but we need to add an enum
> then, since that one is specifically when a websocket protocol
> connection has been made.
>> Additionally, I strongly suggest adding "Accept:" and
>> "If-Modified-Since:" to minilex.c - not being able to safely gzip or
>> do basic cache handling cripples performance.
> More headers sounds reasonable. At the moment its focus as you might
> guess from the name is serving websocket protocol not http. But the
> http stuff could indeed cope with more things.
> Are there any other headers people are interested in processing and
> having available inside libwebsockets? They'd be handled for both pure
> http and if they were present during the upgrade handshake. It's easier
> to do them all at once since fiddling with minilex isn't simple (which
> is why it got left to me I guess).
I found myself with some free time thismorning.
Additional headers supported in minilex + lws
Fix ability to access headers in HTTP service
Add example code to test server for Cookies
>> Patch for lib/handshake.c attached.
> diff --git a/lib/handshake.c b/lib/handshake.c
> index 3007426..00e3bc1 100644
> --- a/lib/handshake.c
> +++ b/lib/handshake.c
> @@ -135,6 +135,11 @@ libwebsocket_read(struct libwebsocket_context
> uri_ptr = lws_hdr_simple_ptr(wsi, WSI_TOKEN_GET_URI);
> uri_len = lws_hdr_total_length(wsi, WSI_TOKEN_GET_URI);
> + if (wsi->protocol->callback &&
> wsi->protocol->callback(context, wsi,
> + LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
> + wsi->user_space, uri_ptr, uri_len))
> + goto bail_nuke_ah;
> /* union transition */
> memset(&wsi->u, 0, sizeof(wsi->u));
More information about the Libwebsockets