[Libwebsockets] two part html

Steve Calfee scalfee at mqidentity.com
Tue Aug 19 17:07:26 CEST 2014

From: Andy Green <extracats at googlemail.com> on behalf of Andy Green <andy at warmcat.com>
Sent: Monday, August 18, 2014 9:13 PM
To: Steve Calfee; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] two part html

On 19 August 2014 10:53:37 GMT+08:00, Steve Calfee <scalfee at mqidentity.com> wrote:
>I think I can do this, but I am not sure. I would like to send a html
>file with the lws sendfile capability. Then I want to send a string of
>json I built in my app as the rest of the html.
>I think all I have to do is when sendfile is done, return 0; then on
>the next http callback I can send my data. If that is true, what
>callback code will I get to indicate it is time for me to send my
>little computed data?


But you will get trouble I think, if sending the file sets the content length header the transaction is over after that much was sent.


Hi Andy,

Who sets the content-length field? I don't have the source here, but I will check it later. If it is set by the lws_sendfile routine, I guess I cannot do it that way.

As a simpler example, say I split a html file arbitrarily in the middle, into 2 files. Then in the http callback I call the lws_sendfile routine twice. Would that work?

Thanks, Steve

More information about the Libwebsockets mailing list