[Libwebsockets] http GET request

Paweł Konowalski pawel.konowalski.delta at gmail.com
Wed Jun 30 12:52:03 CEST 2021

Do you finalize headers before you send the content via lws_write?See
-> lws_finalize_write_http_header(wsi, headers + LWS_PRE, &p, end)
W dniu 30.06.2021, śro o godzinie 10∶37 +0000, użytkownik Avigail Wilk
> Hi,
> What is the right way to implement RestApi using lws with GET
> request?
> As a response to a GET request I want to return the content of a file
> (and optionally editing the file’s content before sending it).
> The way It’s implemented in my project is: 
> when I recognize the Get request in the callback function  (in case
> LWS_CALLBACK_HTTP) I read the file’s content, edit it if needed, and
> then write it using
> lws_write function and returning -1;
> This worked with libwebsockets v2.0 but not with v4.2.0.
> I thought that in v4.2.0 it might be a problem to call lws_write from
> so instead I used lws_callback_on_writable and in 
> LWS_CALLBACK_HTTP_WRITEABLE I used lws_write. But this didn’t solve
> the problem.
> I don’t want to use lws_serve_http_file because I want the option to
> return the content as a string and edit it.
> Any idea of what I am doing wrong? Or what is the right way to
> achieve this?
> Many thanks!
> This message has been scanned for malware by Websense.  www.websense.
> com
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20210630/e307a957/attachment.htm>

More information about the Libwebsockets mailing list