[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.


> 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 

  - add .shtml etc to the default mimetypes


  - 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


  - 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


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


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


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

More information about the Libwebsockets mailing list