[Libwebsockets] HTTP POST Body

Srikar Vadlamani SrikarVadlamani at trafficware.com
Mon Jun 27 16:59:18 CEST 2016

Thanks for the reply, 
When was the form parsing functionality introduced? I am using 2.0.2, it doesn’t seem to have it.

-----Original Message-----
From: Andy Green [mailto:andy at warmcat.com] 
Sent: Saturday, June 25, 2016 6:06 PM
To: Srikar Vadlamani <SrikarVadlamani at trafficware.com>; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] HTTP POST Body

On June 25, 2016 4:01:04 AM GMT+08:00, Srikar Vadlamani <SrikarVadlamani at trafficware.com> wrote:
>I am seeing that Post Data is being split into 2 BODY callbacks, is it 
>normal? If yes, am I supposed to combine data from both callbacks to 
>make a valid packet?

It's "normal" generally, lws passes up what it receives as it receives it.

But usually, the guy sending it doesn't do what you show, just send one byte first.  Maybe check your rx_buffer_size member of your protocol struct is some reasonable number, it defines the max size of the rx chunk that will be assembled and passed here.

However it's open to the sender, the receiver and any tcp intermediary to fragment tcp packets how it likes, including this.

That is why lws has stateful, bytewise parsers for RX handling in the library.  The can deal with fragmentation robustly without buffering.

On master, we have stateful, bytewise POST parsing that will handle fragmentation transparently (including file upload case).

Demo: https://libwebsockets.org/testserver/   use the POST tab

Related code: https://github.com/warmcat/libwebsockets/blob/master/plugins/protocol_post_demo.c

New Doxygen docs: https://libwebsockets.org/lws-api-doc-master/html/group__form-parsing.html


>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list