[Libwebsockets] HTTP method used by request

Andy Green andy at warmcat.com
Mon Jun 1 13:32:19 CEST 2020

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


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


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.


> BR
> Paweł
> 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.
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list