[Libwebsockets] Dummy http server URL modification

Andy Green andy at warmcat.com
Thu Mar 24 19:28:52 CET 2022

On 3/24/22 11:44, Jukka Marin wrote:
> Dear List,
> I'm using lws as a websocket and http server.  Now I need to implement
> a "default path" for the html files if the http client isn't recognized.
> For known clients, the server has separate directories, but for unknown
> clients, it needs to use a common default path.
> Well, I thought I would write a wrapper around lws_callback_http_dummy()
> and check the URL in LWS_CALLBACK_HTTP and change it to the default
> path if necessary, then calling lws_callback_http_dummy().  It seems
> that LWS_CALLBACK_HTTP is not triggered for all requests (odd?) and
> even if I change the URL and pass the changed URL to dummy(), the http
> server still uses the original URL when accessing the filesystem.
> I'm using lws '3.1.99 unknown-build-hash' at the moment.  I wonder if
> what I'm trying to do works better in 4.x?

You should update to current stable (v4.3-stable) anyway, nobody has 
time to support older versions.

Your approach of messing with the copy of the url you're given doesn't 
sound good... the simplest way is probably to redirect the "unknown 
clients" to what you want them to fetch instead.

You can see an example in minimal-http-server-tls.


> Many thanks for any advice. :-)
>    -jm
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list