[Libwebsockets] how to use LWSMPRO_CALLBACK

Avigail Wilk awilk at kramerav.com
Mon Jun 21 13:07:35 CEST 2021


Hi,

I am using libwebsockets v4.2.0.

I want to serve all the HTTP requests through my own callback, so therefor I used  LWSMPRO_CALLBACK in the mounts:

static const struct lws_http_mount mount = {

           /* .mount_next */           NULL,        /* linked-list "next" */

           /* .mountpoint */        "/",        /* mountpoint URL */

           /* .origin */        "http-only",

           /* .def */            NULL,

           /* .protocol */           NULL,

           /* .cgienv */            NULL,

           /* .extra_mimetypes */        NULL,

           /* .interpret */        NULL,

           /* .cgi_timeout */        0,

           /* .cache_max_age */        0,

           /* .auth_mask */        0,

           /* .cache_reusable */        0,

           /* .cache_revalidate */        0,

           /* .cache_intermediaries */    0,

           /* .origin_protocol */        LWSMPRO_CALLBACK,

           /* .mountpoint_len */        1,        /* char count */

           /* .basic_auth_login_file */    NULL,

        };

Where "http-only" is the name of http protocol.

My problem is, that HTTP multi-part post doesn't work.
I get to LWS_CALLBACK_HTTP, and return 0, but I don't get to LWS_CALLBACK_HTTP_BODY and therefor can not complete the request.

I tried to change my mount object to:
static const struct lws_http_mount mount = {
              /* .mount_next */           NULL,        /* linked-list "next" */
              /* .mountpoint */        "/",        /* mountpoint URL */
              /* .origin */        "./www",    /* serve from dir */
              /* .def */            "index.html",    /* default filename */
              /* .protocol */           NULL,
              /* .cgienv */            NULL,
              /* .extra_mimetypes */        NULL,
              /* .interpret */        NULL,
              /* .cgi_timeout */        0,
              /* .cache_max_age */        0,
              /* .auth_mask */        0,
              /* .cache_reusable */        0,
              /* .cache_revalidate */        0,
             /* .cache_intermediaries */    0,
              /* .origin_protocol */        LWSMPRO_FILE,
              /* .mountpoint_len */        1,        /* char count */
              /* .basic_auth_login_file */    NULL,
           };
And the multi-part posted completed as expected.

Do you have any idea of what I am doing wrong?

Thanks for your support


This message has been scanned for malware by Websense. www.websense.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20210621/2ee77d1a/attachment.htm>


More information about the Libwebsockets mailing list