curl / Mailing Lists / curl-library / Single Mail


Re: HTTP redirect to HTTPS stops

From: Ray Satiro via curl-library <>
Date: Wed, 22 Mar 2017 22:09:00 -0400

On 3/22/2017 8:27 PM, Dave S wrote:
> The remaining question is ... should I have been able to debug this
> without tcpdump? The symptoms I ran into was rcc 0 from
> curl_easy_perform, and data buffer empty. Maybe I should have turned
> on a verbose option?

It depends on your ability to understand the data. CURLOPT_VERBOSE [1]
you would've seen the server reply is a redirect. You can also debug at
a more verbose level by setting CURLOPT_DEBUGFUNCTION [2] which requires
some code. There's an example of it in docs/examples/debug.c [3].

I think though you may have a misunderstanding of curl_easy_perform. If
it returns 0 that means the transfer was successful but does not imply
the server response code was success 2xx [4]. That is an important
distinction. If in addition to redirects you turn on CURLOPT_FAILONERROR
[5] then on >= 400 response code curl_easy_perform should in most (all?)
cases fail if that was that last response code received. A better way
though is to use CURLINFO_RESPONSE_CODE [6] and check that you've
received the expected server response code. For example:

  /* curl_easy_perform transfer successful so check HTTP response code */
  long response_code = 0;
  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
  if(response_code/100 != 2) { /* response code is not server status
success 2xx */
    fprintf(stderr, "Error: Unexpected HTTP server response code
%ld.\n", response_code);
    /* handle it here */

> Sidebar question: 7.45.0 isn't quite so embarrassing as 7.29.0, but
> if I try to catch up to the Modern Version (7.53.1) is there a
> shortcut to use my previous config information to configure the new build?

You'll have to explain what you mean by that, what config information?
If you're building often you could automate the steps and put the
options into a shell script, that's what I do. For most people though
it's as easy as ./configure [opts] && make


Received on 2017-03-23