[Libwebsockets] Server Side Includes in lwsws...

Andy Green andy at warmcat.com
Tue Jun 11 20:45:46 CEST 2019



On 6/11/19 2:09 PM, Steve Maynard wrote:

> After browsing the libwebsockets repo, I’m thinking that lwsws doesn’t currently support SSI.

Right.

> If that support is interesting to the lws folks, would it best be implemented in a plugin or adding the additional parser to the file service operation?  I would not add anything other than the include command (exec is way too dangerous for my taste)…

Sure... what I'd do first is implement it in its own protocol as a 
throwaway test app without worrying about lws integration at first... 
basically hook the LWS_CALLBACK_HTTP callback and then use a state 
machine in LWS_CALLBACK_HTTP_WRITEABLE to issue SSI-massaged output a 
chunk at a time.

When that's solid, you would want to

  - add an LWS_WITH_SSI or so default off in CmakeLists.txt and 
./cmake/lws_config.h.in

  - add .shtml etc to the default mimetypes

https://libwebsockets.org/git/libwebsockets/tree/lib/roles/http/server/server.c#n383

  - add some code in lws to determine if it's SSI from the requested 
suffix... here is where it would start feeling it wanted to serve a file

https://libwebsockets.org/git/libwebsockets/tree/lib/roles/http/server/server.c#n1571

  - you can either add a new LRS_ wsi state to indicate you're doing SSI 
parsing, something like lwsi_set_state(wsi, LRS_SSI); and add the state here

https://libwebsockets.org/git/libwebsockets/tree/lib/roles/private.h#n112

or you might find it easier to just add a bit to the wsi to indicate 
that's what it is doing.

https://libwebsockets.org/git/libwebsockets/tree/lib/roles/http/private.h#n245

If so, you must clear the bit in transaction_completed() as the wsi may 
be reused.

  - merge your SSI generating code somewhere in lib/roles/http

-Andy

> 
> Thanks,
> Steve
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 


More information about the Libwebsockets mailing list