curl-library
Re: Need urgent help for HTTPS
Date: Wed, 24 Nov 2010 12:15:40 -0500
Thanks Dan, so if I follow your words can my sequence of operations be like
this:
1) DO HTTP GET by setting options and then doing curl_easy_perform(). This
will send the initial message to server.
2) Then fetch the socket descriptor using some option and set the option
CONNECT_ONLY and do a curl_easy_recv() on that socket handle. (Here I am
confused, if I say CONNECT_ONLY before any thing starts I will have to send
HTTP GET by my own and if I dont do then I will not be able to use
curl_easy_send() and recv() because documentation says curl_easy_send() can
be used only when we set CONNECT_ONLY option)
3) when data will be available, curl_easy_recv() will be called and I will
get my handle called where I will get HTTP header+my protocol data. If this
is right then it means, I will have to parse HTTP header by my own and I can
not use libcurl's callback for parsing HTTP header.
4) When I want to send response, prepare payload and call curl_easy_send().
In this step, I will have to prepare HTTP GET header by my own and on top of
that my protocol data and then send to server.
If I do operations by using curl_easy_send() and curl_easy_recv() functions
then I am not using much of libcurl's functionality right?
On Wed, Nov 24, 2010 at 11:28 AM, Dan Fandrich <dan_at_coneharvesters.com>wrote:
> On Wed, Nov 24, 2010 at 11:01:56AM -0500, amit paliwal wrote:
> > Step 3 and 4 can be achieved if we use server -sent events. These
> facilitates
> > the server to send messages asynchronously. Now my question is how can I
> > achieve it using libcurl, or can I achieve it or not. can it be done by
> > registering callbacks for header, read and write functions or do i just
> need to
> > use CONNECT_ONLY option and then do everythign manually by myself?
> >
> > Can I do curl_easy_perform() multiple times, whenever I need to do
> something.
> > Can I do something like, when I have some data to send to server, I can
> pass my
> > function as callback to read function and then do curl_easy_perfom()?
>
> curl_easy_perfom() will do an entire HTTP transaction, which as Michael
> points
> out, you're not doing once the server starts sending unsolicited data. I
> don't see why you shouldn't be able to do curl_easy_perfom() to do the
> HTTP stuff first, then switch to curl_easy_recv() to get the unsolicited
> data. You'll have to make sure the server sends a Connection: Keep-Alive
> header
> (or otherwise specifies a persistent connection) during the HTTP phase so
> libcurl doesn't tear down the socket. You might also end up with a race
> condition if the server-sent asynchronous data is sent in the same TCP
> frame as the end of the HTTP transaction (e.g. because of Nagle's
> algorithm) if libcurl doesn't return buffered data following the previous
> HTTP response in curl_easy_recv() (I think it does this, so you're probably
> OK).
>
> >>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-24