[Libwebsockets] latest commit breaks DomTerm's http serving

Andy Green andy at warmcat.com
Wed Oct 25 09:24:56 CEST 2017



On 10/25/2017 02:23 PM, Per Bothner wrote:
> On 10/24/2017 10:53 PM, Andy Green wrote:
>> Well, gdb is good if it randomly does something like crash.  But 
>> normally I debug by lwsl_notice() or whatever.
> 
> (Most of the time, I too use fprintf or the equivalent.)
> 
>> The underlying issue is because you're providing a "by hand" http 
>> protocol instead of using the dummy one,
> 
> Hm.  It may be the case that the "by hand" http protocol is no longer 
> needed (except when using
> COMPILED_IN_RESOURCES).  Though I have some ideas where it might be 
> useful, so I'll keep it for now.
> 
>> a required bit of magic ending the http transaction when it finishes 
>> sending the file is missing.
> 
> Would it be practical for lws to do this magic automagically?  Lws has 
> lots of great features,
> but it certainly has a tricky API. (Of course a lot of that is because 
> it's using C and aiming
> for low overhead, so that is understandable.)

lws really wants to do it automatically... for example it's fine to not 
provide any protocols (NULL when creating the context / vhost) and lws 
will use the built-in "dummy" one that does the Right Things, plus any 
protocols that came in from plugins found at runtime.  Lwsws and 
libwebsockets-test-server-v2.0 take this approach.  Basically it means 
the callbacks only exist in the protocol plugins.

A middle way is to have your own callback for protocols[0], but have it 
call through to lws_callback_http_dummy() for unhandled / default: or 
not fully handled callbacks, that also would have dealt with this 
problem automatically too without having to know the details.

Or you can provide a protocols[0] that points directly to 
lws_callback_http_dummy() instead of any new callback, just to make up 
the numbers before adding your own static protocols.

>> So this doesn't need any patch on lws just on DomTerm.
>> I sent the patch and another little one as a github PR.
> 
> Many thanks for this patch - and lws in general!
> 
>> DomTerm is pretty cool once it started, I was surprised to see a 
>> terminal on my box open in FFOX...
> 
> That's what is supposed to happen ...
> 
> DomTerm is even nicer when run using electron or qtdomterm, as you get 
> appropriate menues and the
> browser gets less in the way.
> 
> I have session management a la tmux/screen mostly working.  After that 
> my goal is re-factor
> qtdomterm so Qt only handles the GUI, while the lws-based domterm code 
> handles the other stuff.

I'm glad it's useful.

-Andy

> Thanks again.



More information about the Libwebsockets mailing list