Or use chunked transfer encoding if the body length isn't known in advance. http://en.wikipedia.org/wiki/Chunked_transfer_encoding
On Mon, Nov 1, 2010 at 9:54 PM, Marcel Holtmann <[email protected]> wrote: > Hi Mohamed, > > > Currently we support only GET method which does not need http request > > body only header is needed to support GET method. With POST we need to > > have both header and body parts in HTTP request. So user need to pass > > the body part which we can do by implementing one of these methods: > > * change g_web_request by adding new string parameter which is the > > body. > > OR > > * Add new api to set http request body g_web_set_body. > > OR > > Append the body part to the end of url we pass in g_web_request, > this > > requires change in url_parse function. > > the latter one is not really how this works. You can have any arbitrary > body with different content there. Look at RESTful API or JSON or other > HTTP based protocols. They can have random about of body content. > > So I already split this into g_web_request_get() and then also a > g_web_request_post(). If we try to overload one request function it will > become pretty big. That is not really a good idea. > > I was initially thinking to just give the body content as parameter to > that function, but it turns out that we have to keep copying that body > around. The asynchronous nature of the library forces us to a little bit > different approach. > > So that means that just setting the body is also out of the question. > > What I am currently thinking is a proper input callback that can feed > one or multiple times input chunks. > > typedef gboolean (*GWebInputFunc)(const guint8 **data, gsize *length, > gpointer user_data); > > guint g_web_request_post(GWeb *web, const char *url, > const char *type, GWebInputFunc input, > GWebResultFunc func, gpointer user_data); > > When the input functions return TRUE, then there is more data, if it > returns FALSE, then that was the last bit. > > The only problem that I still see is when constructing the header for > the Content-Length. However initially we might get away with calling it > just once. And assuming that data as full body. > > So essentially we have to just call that function when constructing the > header for the post. And include its feedback as body. > > I might have an initial stab at this. It will be only some initial code > to get this going since I need it for testing WISPr. So keep an eye on > the repository. > > Regards > > Marcel > > > _______________________________________________ > connman mailing list > [email protected] > http://lists.connman.net/listinfo/connman > _______________________________________________ connman mailing list [email protected] http://lists.connman.net/listinfo/connman
