[Libwebsockets] strange log message from lws

Thomas Spitz thomas.spitz at hestia-france.com
Wed Mar 22 15:26:31 CET 2017


Hello everyone,

I'm using lws to provide an HTTP API for my device and it works well but
there is a log message from lws that I shouldn't get and I don't understand
where it comes from and why.

Some of my code :

> /* list of supported protocols and callbacks */
> static struct lws_protocols protocols[] = {
> /* first protocol must always be HTTP handler */
> { "http-only", /* name */
> callback_http_dummy, /* callback */
> 0, /* per_session_data_size */
> 0, /* max frame size / rx buffer */
> },
> *{ "api-stat", /* name */*
> * callback_api_stat, /* callback */*
> * sizeof(struct per_session_data__http), /* per_session_data_size */*
> * 0, /* max frame size / rx buffer */** }*, { NULL, NULL, 0, 0 } /*
> terminator */
> };
> /*
>  * mount a handler for a section of the URL space
>  */
> static/*const*/struct lws_http_mount mount_ssl_api_stat = { NULL, /*
> linked-list pointer to next*/
> "/api/stat", /* mountpoint in URL namespace on this vhost */
> "api-stat", /* handler */
> NULL, /* default filename if none given */
> NULL,
> NULL,
> NULL,
> NULL, 0, 0, 0, 0, 0, 0, LWSMPRO_CALLBACK, /* origin points to a callback */
> 9/*strlen("/api/stat")*/, /*ie length of the mountpoint */
> };
> int callback_api_stat(struct lws *wsi, enum lws_callback_reasons reason,
> void *user, void *in, size_t len /*>=9 : strlen("/api/stat*/) {
> printf("callback_api_stat reason=%d", reason);
> switch (reason) {
> case LWS_CALLBACK_HTTP:
> lwsl_notice("lws_http_serve: %s", (char *) in);
> break;
> case LWS_CALLBACK_CHECK_ACCESS_RIGHTS:
> printf("end LWS_CALLBACK_CHECK_ACCESS_RIGHTS");
> break;
> default:
> break;
> }
> return 0;
> }

Here is console output:

> callback_api_stat reason=49
> callback_api_stat reason=51
> *lwsts[1258]: Unable to open 'api-stat//resource/1/2017/3/22'*
> callback_api_stat reason=12
> lwsts[1258]: lws_http_serve: /api/stat/resource/1/2017/3/22

when I do that request:

> https://192.168.1.16/api/stat/resource/1/2017/3/22

I don't understand why lws try to "open"
*api-stat//resource/1/2017/3/22 *between
LWS_CALLBACK_CHECK_ACCESS_RIGHTS
and LWS_CALLBACK_HTTP?
Furthermore, I wonder why lws adds 2 times '/' after api-stat?

I'm using stable version lws 2.2.0 (version compiled on 20170321)

Thanks in advance for your answer.

Best regards,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20170322/2789b306/attachment.html>


More information about the Libwebsockets mailing list