[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

        "Accept:",
        "If-Modified-Since:",
        "Accept-Encoding:",
        "Accept-Language:",
        "Pragma:",
        "Cache-Control:",
        "Authorization:",
        "Cookie:",
        "Content-Type:",
        "Date:",
        "Range:",
        "Referer:"

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=cc13c6f187f47fd31a377d05477f90c0fd7f7452

introduce LWS_CALLBACK_FILTER_HTTP_CONNECTION

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=19895bcfd4e89f96100ab2dca041e965973f8e2b

Fix ability to access headers in HTTP service

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=84fd949e05d011410dba2abe93dfd2fd7dff1589

Add example code to test server for Cookies

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=6cd8880f23354ceeba75d641379c8f07407b0570

-Andy


> -Andy
>
>> Patch for lib/handshake.c attached.
>>
>> /Johan
>>
>
> 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
> *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 mailing list