[Libwebsockets] libwebsocket problem

Andy Green andy at warmcat.com
Thu May 16 12:18:55 CEST 2019



On 5/16/19 9:12 AM, Wei, Catherine wrote:
> Thanks for the API, since the number of the parameters are also unknow, so I didn't use the API. I added a patch to keep the parameters to the url, so I can easily get the request url with parameters with current interface. Still thanks. By the way, if there is any unproper place in my patch, please let me know.

I appreciate the urge to send me code, but the existing apis can do 
everything you needed... look at the implementation of the by_name() 
api... it's based on the other api.  It just looks at each fragment 
until it finds it has asked for one that doesn't exist.

LWS_VISIBLE LWS_EXTERN const char *
lws_get_urlarg_by_name(struct lws *wsi, const char *name, char *buf, int 
len)
{
         int n = 0, sl = (int)strlen(name);

         while (lws_hdr_copy_fragment(wsi, buf, len,
                           WSI_TOKEN_HTTP_URI_ARGS, n) >= 0) {

                 if (!strncmp(buf, name, sl))
                         return buf + sl;

                 n++;
         }

         return NULL;
}

https://libwebsockets.org/git/libwebsockets/tree/lib/core-net/wsi.c#n504-519

-Andy


More information about the Libwebsockets mailing list