[Libwebsockets] libwebsockets based http CLIENT
andy at warmcat.com
Mon Apr 18 09:01:20 CEST 2016
On 04/18/2016 02:40 PM, Zlotin, Lev wrote:
> I’m trying to implement the http client( currently – simple prototype )
> based on libwebsockets; I met some issues:
> 1.Lack of any documentation/tutorial/etc. Can you point me to any
> documentation on development of http client?
Until the current stuff in master, the client part of lws assumes that
you are wanting a websocket connection, not an http one. It has always
handled server http responses but only in order to get itself upgraded
to ws (it is libwebsockets after all...)
However on master, there's an optional method member of
lws_client_connect_info you can set to "GET" to have it work just at
http and not ws. This info is in the libwebsockets.h on master.
* @method: if non-NULL, do this http method instead of ws[s] upgrade.
* use "GET" to be a simple http client connection
The test client on master branch supports connecting over http[s] like this
however this isn't complete yet, master uses it for http proxying not
for http client.
> 2.I built something base on echo client in examples. However, I’m
> getting crash in a library, which is related to “redirect”: during
> redirect function “lws_client_reset” is called, which writes NULL to
> wsi->protocol. Wsi->protocol is executed after without any check for NULL.
Sorry what exactly causes the 'redirect'... the client is connecting to
a server that requests a redirect?
From what you're saying you should look at master branch test-client.
I'll complete the support in test-client shortly and then basing off
that should work well.
> Although after fixing of this issue, nothing is working
> Can you please point me to any tutorial/documentation/sample
> implementation for http/https client with libwebsockets?
> *Lev Zlotin*
> *Lev.zlotin at intel.com*
> Intel Israel (74) Limited
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets