[Libwebsockets] HTTP method used by request

Pawel Konowalski Pawel.Konowalski at deltaww.com
Mon Jun 1 13:50:03 CEST 2020


W dniu 01.06.2020, pon o godzinie 12∶32 +0100, użytkownik Andy Green
napisał:
>
> On 6/1/20 12:24 PM, Pawel Konowalski wrote:
> > Dear team,
> >
> > To make a client HTTP request with specifying http method I need to
> > fill
> > an appropriate field:
> > struct lws_client_connect_info.method = "GET/PUT/POST/DELETE/and so
> > on"
> >
> > However I didn't find any way to find out what method is requested
> > from
> > server (using lws, of course).
> > The hint can be headers WSI_TOKEN_GET_URI or WSI_TOKEN_POST_URI.
> > However
> > it is not enough to find out the exact http method.
> > For example:
> > When PUT or DELETE methods are requested then both headers are
> > empty
> > what is normal. But it doesn't point a http method in other cases.
> > How to do it?
>
> On h2 you can use :method / WSI_TOKEN_HTTP_COLON_METHOD
>
> https://libwebsockets.org/git/libwebsockets/tree/include/libwebsocket
> s/lws-http.h#n267
>
> On h1, it took the approach back in the day to put the path part of
> the
> URI in a method-specific header.  And it has followed that until now
>
> WSI_TOKEN_GET_URI
>          WSI_TOKEN_POST_URI
>          WSI_TOKEN_PATCH_URI
>          WSI_TOKEN_PUT_URI
>          WSI_TOKEN_DELETE_URI
> WSI_TOKEN_HEAD_URI
>
> These cover all the normal, CRUD and HEAD usecases.  Only one of
> them
> will have a nonzero header length and that indicates what the
> transaction method was.
>
> FWIW although h2 also has it in :method, for backwards compatibility
> it
> also defines a matching method the same way.
>
> -Andy
You are right and it's working.
I've read only documentation without digging into sources. ;)
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
[Delta Electronics (Poland) Sp.z.o.o]
********************************************************************************************************************************
Delta Electronics (Poland) Sp.z.o.o. is established at Warsaw, Poland, and is registered with the Commercial Register under no.214778.


More information about the Libwebsockets mailing list