[Libwebsockets] Send http response after parsing request body
andy at warmcat.com
Thu Mar 14 21:09:59 CET 2019
On March 14, 2019 10:32:01 PM GMT+08:00, Kun Zhao <kzhdev at gmail.com> wrote:
>Thanks for your response. One more quick question, there is
>lws_context_creation_info, when and how this is used? I tried to set it
>no log file is created.
Lws http serving optionally supports per-vhost Apache style access log generation, if the cmake option LWS_WITH_ACCESS_LOG is enabled and this .log_filepath is non-NULL at vhost creation time.
If you instead want to control where the lwsl_...() lws logs go, you can set the emit function to your own one or some canned ones, including syslog.
>On Wed, Mar 13, 2019 at 5:28 PM Andy Green <andy at warmcat.com> wrote:
>> On March 14, 2019 4:28:22 AM GMT+08:00, Kun Zhao <kzhdev at gmail.com>
>> >Hi Andy,
>> >I need to response a POST after parsing the request body. Can I call
>> >lws_add_http_common_headers and lws_finalize_write_http_header in
>> >LWS_CALLBACK_HTTP_BODY_COMPLETION? In this case, should I call
>> >lws_callback_on_writable(wsi) in LWS_CALLBACK_HTTP or in
>> >LWS_CALLBACK_HTTP_BODY_COMPLETION? In your minimal samples, you
>> >redirect the request to another page. Could you add an example to
>> >to properly send a dynamic response after parsing the request body?
>> Take a look at the demo post protocol plugin, it shows how to do all
>> The minimal examples try to be minimal so it's not hard to see how to
>> whatever the main point is. But historically the demos were in big
>> monolithic apps... these got mostly split out into clean protocol
>> while back... so there are more examples to be found in /plugins.
>> plugins are used in lwsws on https://libwebsockets.org/testserver and
>> built into the now much smaller libwebsockets-test-server
>> >in addition, when returning the http_callack function, what is the
>> >of return 0, 1, and -1?
>> Unless the specific callback interprets it differently, 0 indicates
>> problem (unhandled callbacks should return 0), and nonzero means
>> bad happened and the stream (h2) or connection (h1) must be closed.
More information about the Libwebsockets