curl-library
A quick hack to support Websocket with libcurl
Date: Sun, 26 Jan 2014 10:09:42 +0100
Hello all, I'm new here :)
I'm writing because I found a way do kind of HTTP UPGRADE requests when we
use multi handle, but as I'm wondering if there are cleaner ways, so I'm
writing on the mailing list so that everyone can join in.
Daniel told me it can be related to the work made for HTTP2 in
lib/http2.[ch]
I actually made a github pull request there :
https://github.com/bagder/curl/pull/86
So the idea is to be able to "detach" a easy handle from the multi handle.
When it's in detached state, we can safely use curl_easy_send and
curl_easy_recv :
1) add a easy handle wich represent your UPGRADE http request,
with CURLOPT_HEADERFUNCTION set
2) on the last last header, do the following to detach the connection
curl_easy_pause(easy_handle, CURLPAUSE_ALL);
curl_easy_setopt(easy_handle, CURLOPT_FORBID_REUSE, 1);
curl_easy_setopt(easy_handle, CURLOPT_CONNECT_ONLY, 1);
3) using the multi port you have, you can safely poll your socket
for data, and use curl_easy_send/curl_easy_recv to exchange
data with the connection
Just need the little patch I sent, a websocket parser like wslay at
http://wslay.sourceforge.net/.
And I need to write a test for that...
Comments are welcome
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-26