cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: How do I correlate two responses

From: Vijay <nags.vijay_at_gmail.com>
Date: Thu, 28 Feb 2008 14:01:16 +0530

Am having a callback function
header_callback(char *ptr, size_t msize, size_t nmemb, void *stream);

and am setting option as
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback

then in 1 thread am doing
curl_easy_perform(curl)

in one more thread also am doing curl_easy_perform(curl) for the same URL
eg: http://www.gmail.com is the one i tried

but callback function is same, so am getting callback,
but how can i correlated that the http response I got is for which request.

Am getting callback for both the request, but am not able to figure out for
which is the
http response for which request.

Is there anyway to find whenever you send an Http Request,
the Http response we got is for which request sent from us.
Using only one CURL *curl;

Attached my code sample :)

On Thu, Feb 28, 2008 at 12:57 PM, <curl-library-request_at_cool.haxx.se> wrote:

> Send curl-library mailing list submissions to
> curl-library_at_cool.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
> or, via email, send a message with subject or body 'help' to
> curl-library-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> curl-library-owner_at_cool.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of curl-library digest..."
>
>
> Today's Topics:
>
> 1. Re: Google Summer of Code ? ( j?r?me Muffat-M?ridol )
> 2. Re: Google Summer of Code ? (Christian Vogt)
> 3. Re: curl_easy_setopt() typechecker, try2 (Michal Marek)
> 4. Re: curl_easy_setopt() typechecker, try2 (Daniel Stenberg)
> 5. How do I correlate two responses (Vijay)
> 6. Re: curl_easy_setopt() typechecker, try2 (Michal Marek)
> 7. Re: How do I correlate two responses (Michal Marek)
> 8. Re: Google Summer of Code ? (Richard Atterer)
> 9. Re: Negotiate: crash (Anatoli Tubman)
> 10. Re: How do I correlate two responses (Bharani kumar srinivasan)
> 11. RE: Curllib on vista? (Guenter Knauf)
> 12. Re: curl_easy_setopt() typechecker, try2 (Jamie Lokier)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 27 Feb 2008 12:06:22 +0100
> From: " j?r?me Muffat-M?ridol " <jmuffat_at_webphotomag.com>
> Subject: Re: Google Summer of Code ?
> To: "libcurl development" <curl-library_at_cool.haxx.se>
> Message-ID:
> <cb8b9a8d0802270306u48befbe0j2c3916bc807683e0_at_mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Feb 26, 2008 at 4:37 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> > Hey
> >
> > Just in case someone can come up with any cool projects for possible
> students,
> > we could apply for Google's Summer of Code 2008.
> >
> > Is there anything somewhat largish anyone thinks would fit?
> >
> > --
> > Commercial curl and libcurl Technical Support:
> http://haxx.se/curl.html
> >
>
> http caching.
>
> This isn't as simple a problem as it might seem as there are potential
> issues with security and also because depending on use cases, you will
> want to store the cache in different places with different sizes...
> ___________________________________________
> J?r?me Muffat-M?ridol - www.gpuViewer.com
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 27 Feb 2008 12:40:54 +0100
> From: Christian Vogt <christian.vogt_at_loewe-komp.de>
> Subject: Re: Google Summer of Code ?
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <47C54C46.1000407_at_loewe-komp.de>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
>
> >> Is there anything somewhat largish anyone thinks would fit?
> >
> > Maybe streaming protocols?
>
>
> Yeah, nice idea! I vote for (AV) streaming protocols.
> (But I don't know if that would be largish enough, though. ;-)
>
> Christian
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 27 Feb 2008 12:54:39 +0100
> From: Michal Marek <mmarek_at_suse.cz>
> Subject: Re: curl_easy_setopt() typechecker, try2
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <47C54F7F.4020007_at_suse.cz>
> Content-Type: text/plain; charset=UTF-8
>
> Daniel Stenberg wrote:
> > I applied the patch locally and I installed gcc 4.3 for the purpose of
> testing
> > out your work (gcc-4.3 (Debian 4.3-20080219-1) 4.3.0 20080219
> (prerelease)
> > [gcc-4_3-branch revision 132456]) but for some reason I can't get it to
> > produce any warnings when I try to build a test application using this
> > compiler and some funky bad usages of curl_easy_setopt() ... I'm a bit
> puzzled
> > why.
>
> That's strange, did you compile with optimizations? My gcc is only a few
> days newer:
> gcc version 4.3.0 20080221 (prerelease) [gcc-4_3-branch revision 132521]
> (SUSE Linux)
> but it works with -O and higher:
> $ cat test.c
> #include <curl/curl.h>
>
> int main()
> {
> CURL *h = curl_easy_init();
> curl_easy_setopt(h, CURLOPT_URL, 2);
> curl_easy_perform(h);
> return 0;
> }
> $ gcc -O -Wall -I ./include/ -lcurl test.c
> test.c: In function ?main?:
> test.c:6: warning: call to ?_curl_easy_setopt_err_string? declared with
> attribute warning: curl_easy_setopt expects a string (char* or char[])
> argument for this option
>
> Michal
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 27 Feb 2008 13:14:49 +0100 (CET)
> From: Daniel Stenberg <daniel_at_haxx.se>
> Subject: Re: curl_easy_setopt() typechecker, try2
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <Pine.LNX.4.64.0802271311440.24173_at_yvahk3.pbagnpgbe.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Wed, 27 Feb 2008, Michal Marek wrote:
>
> > That's strange, did you compile with optimizations?
>
> Oh, me is silly! I didn't use -O at all, just -W and -Wall... with -O it
> works
> just fine!
>
> And I get to see this:
>
> debugit.c:49: warning: call to '_curl_easy_setopt_err_long' declared with
> attribute warning: curl_easy_setopt expects a long argument for this
> option
>
> ... where line 49 is:
>
> curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, TRUE);
>
> (and TRUE is a #define 1, and this is a 32bit arch)
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 27 Feb 2008 17:44:57 +0530
> From: Vijay <nags.vijay_at_gmail.com>
> Subject: How do I correlate two responses
> To: curl-library_at_cool.haxx.se
> Message-ID:
> <2549ebb10802270414i5dd1530ewcf5a95df2be39ac5_at_mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
> Am posting two http request(same URL text), from different threads.
> Am getting http response but how do I correlate which response is for
> which
> request.
> Please do let me know.
>
> regards,
> Nagarajan
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://cool.haxx.se/pipermail/curl-library/attachments/20080227/34506fc3/attachment-0001.htm
>
> ------------------------------
>
> Message: 6
> Date: Wed, 27 Feb 2008 13:46:40 +0100
> From: Michal Marek <mmarek_at_suse.cz>
> Subject: Re: curl_easy_setopt() typechecker, try2
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <47C55BB0.7050006_at_suse.cz>
> Content-Type: text/plain; charset=UTF-8
>
> Daniel Stenberg wrote:
> > On Wed, 27 Feb 2008, Michal Marek wrote:
> >
> >> That's strange, did you compile with optimizations?
> >
> > Oh, me is silly! I didn't use -O at all, just -W and -Wall... with -O it
> works
> > just fine!
>
> Yes, unfortunately without -O gcc can't prove the constness of the
> option code :(
>
>
> > And I get to see this:
> >
> > debugit.c:49: warning: call to '_curl_easy_setopt_err_long' declared
> with
> > attribute warning: curl_easy_setopt expects a long argument for this
> option
> >
> > ... where line 49 is:
> >
> > curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, TRUE);
> >
> > (and TRUE is a #define 1, and this is a 32bit arch)
>
> The warning is currently intended and actually correct, although a bit
> pedantic. E.g this is what printf("%ld\n", 1) produces (with recent
> enough gcc and glibc):
>
> $ gcc -m32 -Wall print.c
> print.c: In function ?main?:
> print.c:5: warning: format ?%ld? expects type ?long int?, but argument 2
> has type ?int?
> $ file a.out
> a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
> GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped
>
> The question is whether we will make the world a better place by warning
> about this or not. Given that this warning pops up in about every code
> using curl, I'm probably leaning towards not warning about this for now.
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 27 Feb 2008 13:57:20 +0100
> From: Michal Marek <mmarek_at_suse.cz>
> Subject: Re: How do I correlate two responses
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <47C55E30.3020407_at_suse.cz>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Vijay wrote:
> > Am posting two http request(same URL text), from different threads.
> > Am getting http response but how do I correlate which response is for
> which
> > request.
>
> And you're using the same write callback, right? Then you want to pass
> some context information to the callback by setting CURLOPT_WRITEDATA.
> See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEDATA
>
> hth,
> Michal
>
>
> ------------------------------
>
> Message: 8
> Date: Wed, 27 Feb 2008 14:03:27 +0100
> From: Richard Atterer <richard_at_2008.atterer.net>
> Subject: Re: Google Summer of Code ?
> To: curl-library_at_cool.haxx.se
> Message-ID: <20080227130327.GB17940_at_fluff.lan>
> Content-Type: text/plain; charset=iso-8859-15
>
> On Wed, Feb 27, 2008 at 12:06:22PM +0100, j?r?me Muffat-M?ridol wrote:
> > http caching.
>
> Yeah, I thought the same. Or rather, a "caching framework" which allows
> the
> user to define callbacks for actually storing the data in a filesystem,
> database, or whatever he prefers.
>
> Some aspects of the HTTP standard are not well-known and people are bound
> to get them wrong if they implement caching themselves, e.g. the "Vary"
> and
> "Etag" headers.
>
> Cheers,
>
> Richard
>
> --
> __ _
> |_) /| Richard Atterer | GnuPG key: 888354F7
> | \/?| http://atterer.net | 08A9 7B7D 3D13 3EF2 3D25 D157 79E6 F6DC
> 8883 54F7
> ? '` ?
>
>
> ------------------------------
>
> Message: 9
> Date: Wed, 27 Feb 2008 16:55:36 +0200
> From: Anatoli Tubman <anatolit_at_checkpoint.com>
> Subject: Re: Negotiate: crash
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <47C579E8.2070209_at_checkpoint.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> OK I think I have figured this out.
>
> There are two problems (at least) regarding Kerberos authentication,
> when more than one request is made within the same connection.
>
> 1. The first problem is the crash that results from incomplete
> clean-up of the negotiation state.
> 2. After this is fixed, the second problem pops out: libcurl
> reuses the authentication header from the first request. This
> is because the allocptr.userpwd is not cleaned up between the
> first request and the second.
> 3. The second problem went unnoticed because of the bug (?) in
> mod_auth_kerb, which is succeptible to replay attacks. I didn't
> have another web server with Kerberos support to test against.
> 4. But now I have IIS, and it turns out that IIS detects the replay and
> returns 401 for the second request.
>
> It follows that my second attempt to patch libcurl was completely wrong.
> The authentication token should never be reused, and the negotiation
> state should be cleaned up after each request. In addition,
> allocptr.userpwd should be cleaned after each request too. As far as I
> can tell it doesn't hurt other authentication methods, because their
> handlers clean up this field anyway.
>
> So there's a minimal patch of the two files that works for me. Please
> feel free to criticise.
>
> Best regards
>
> --
> anatoli tubman
> -------------- next part --------------
> An embedded and charset-unspecified text was scrubbed...
> Name: patch
> Url:
> http://cool.haxx.se/pipermail/curl-library/attachments/20080227/55e02696/attachment.txt
>
> ------------------------------
>
> Message: 10
> Date: Wed, 27 Feb 2008 09:03:31 -0800
> From: "Bharani kumar srinivasan" <ganeshfriends_at_gmail.com>
> Subject: Re: How do I correlate two responses
> To: "libcurl development" <curl-library_at_cool.haxx.se>
> Message-ID:
> <85c7f7e00802270903t48d1c503h7807c0e771d2a598_at_mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> cant get what u r saying..
> send the code example
>
> On 2/27/08, Michal Marek <mmarek_at_suse.cz> wrote:
> > Vijay wrote:
> > > Am posting two http request(same URL text), from different threads.
> > > Am getting http response but how do I correlate which response is for
> > which
> > > request.
> >
> > And you're using the same write callback, right? Then you want to pass
> > some context information to the callback by setting CURLOPT_WRITEDATA.
> > See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEDATA
> >
> > hth,
> > Michal
> >
>
>
> --
>
> With regards
> B.S.Bharanikumar
> SNR Tech
> Chennai
>
>
> ------------------------------
>
> Message: 11
> Date: Wed, 27 Feb 2008 18:39:42 +0100
> From: Guenter Knauf <eflash_at_gmx.net>
> Subject: RE: Curllib on vista?
> To: curl-library_at_cool.haxx.se
> Message-ID: <4OwgOTishWKdloBzXCxqe9VLggEOjoiGNzrhP83BqIP_at_akmail>
> Content-Type: text/plain; charset=us-ascii
>
> Hi,
> > Thanks for the response, I tried using the off the shelf dll (7.18 ) and
> > I am still having the problem where if you unplug the network cable in
> > the middle of a transmission, the library never returns from the
> > easy_perform call, but this only happens on vista. On XP the library
> > returns with a network error. Has anyone else tried unplugging the
> > cable during transmission on vista?
> I'd suggest that you try same with some other apps, f.e. wget, putty, etc;
> if you find same behavior with these I would assume a bug in the Vista
> Winsock layer.
>
> Guenter.
>
>
>
>
> ------------------------------
>
> Message: 12
> Date: Thu, 28 Feb 2008 07:27:02 +0000
> From: Jamie Lokier <jamie_at_shareable.org>
> Subject: Re: curl_easy_setopt() typechecker, try2
> To: libcurl development <curl-library_at_cool.haxx.se>
> Message-ID: <20080228072701.GD7876_at_shareable.org>
> Content-Type: text/plain; charset=utf-8
>
> Michal Marek wrote:
> > > curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, TRUE);
> > >
> > > (and TRUE is a #define 1, and this is a 32bit arch)
> >
> > The warning is currently intended and actually correct, although a bit
> > pedantic.
>
> If the argument is fetched in curl_easy_setopt using `va_arg(ap,long)',
> then the code may be actually buggy on 64-bit architectures.
>
> The caller may pass a 32-bit value on the stack, and the callee parse
> a 64-bit value from the stack, so 32 bits of the value seen in the
> callee can be garbage. In this case, if you passed FALSE, the callee
> might interpret it as TRUE instead. Not what you want, a real bug.
>
> > E.g this is what printf("%ld\n", 1) produces (with recent
> > enough gcc and glibc):
> >
> > $ gcc -m32 -Wall print.c
> > print.c: In function ?main?:
> > print.c:5: warning: format ?%ld? expects type ?long int?, but argument 2
> > has type ?int?
> > $ file a.out
> > a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
> > GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped
>
> Same reason. On a 64-bit architecture, it's calling with 32-bit value
> 1, but the callee parses 64-bits from the argument stack, reading 32
> bits of garbage. It really might print a value different from 1.
>
> -- Jamie
>
>
> ------------------------------
>
> _______________________________________________
> curl-library mailing list
> curl-library_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
>
>
> End of curl-library Digest, Vol 30, Issue 53
> ********************************************
>

-- 
VIJAY


Received on 2008-02-28