cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: 转发: Why libcurl sent two request packet for on "curl_multi_add_handle"?

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 17 Apr 2012 13:19:11 +0200

On Tue, Apr 17, 2012 at 06:44:21AM -0400, Jason Liu wrote:
> I set these options, maybe not exactly:
> curl_easy_setopt(m_handle, CURLOPT_VERBOSE, 1);

Note that this (and all the binary constant options) require a long to
be passed in, not an int.

> As I captured the packets, first time, it sent one request without the
> degist credentials, the second time, it sent with the degist
> credentials. I did only call the "curl_multi_add_handle" one time.

That's how Digest works. The server sends a nonce (among other data)
that the client uses to calculate its authorization header. The client
can't do this without first receiving a response from the server. The first
Digest request therefore requires at least two round trips to the server.
Subsequent transactions don't require the extra round trip, at least
until the time stamp expires.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-17