cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Choosing between CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 1 Nov 2015 00:15:48 +0100 (CET)

On Fri, 30 Oct 2015, John Marshall wrote:

> I have an easy handle (used via the multi interface) on which I have set
> CURLOPT_FAILONERROR.
>
> If either a direct connection or a CONNECT via a proxy fails, I get notified
> via CURLE_HTTP_RETURNED_ERROR. When handling this, how do I know which one
> of CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE to consult to get
> the relevant http status to report back to the user? Perhaps I should just
> check both and hope that exactly one is non-zero (as is probably the case
> for the first connection on an easy handle)?

They can also both be non-zero, if CONNECT succeeds and the HTTP request gets
an error.

You can actually check the transfer return code because FAILONERROR only
affects the actual request to the server and not the CONNECT to the proxy, so
a failed CONNECT will cause a CURLE_RECV_ERROR.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-11-01