cURL / Mailing Lists / curl-library / Single Mail

curl-library

Choosing between CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE

From: John Marshall <jm18_at_sanger.ac.uk>
Date: Fri, 30 Oct 2015 12:52:56 +0000

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)?

I've scanned curl_easy_getinfo() -- possibly too quickly -- and not spotted a way to detect whether a failure is due to a proxy, or even whether a connection involves a proxy.

I can use CURLOPT_ERRORBUFFER to get a human-readable message, and probably I will write that to a log in verbose mode. However in this application, error handling is done by shoehorning stuff into errno, so primarily I want to find the actual numeric HTTP status code so I can translate it into an appropriate errno equivalent. Hence the question above.

Cheers,

    John

-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-10-30