curl-library
Re: HTTP redirect to HTTPS stops
Date: Thu, 23 Mar 2017 00:10:26 -0700
On Wed, Mar 22, 2017 at 7:09 PM, Ray Satiro via curl-library
<curl-library_at_cool.haxx.se> wrote:
> 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.
I give people lots of opportunity to teach me something new.
> 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 */
> }
This is good to know. The wininet version of this code (forgive my
language) always puts the 200 on my plate, which was interesting for
the period where the server was returning 200 but a 0-length body,
when I expected either useful data or a server explanation of why no
data was returned.
> 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
Well, it's the result of running ./configure [for 45] that I wanted to
use for 53. You can guess that I don't do that step often, so the
[opts] don't quite roll off my tongue (so to speak).
> [1]: https://curl.haxx.se/libcurl/c/CURLOPT_VERBOSE.html
> [2]: https://curl.haxx.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html
> [3]: https://github.com/curl/curl/blob/master/docs/examples/debug.c
> [4]: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
^
A frequently opened page here.
> [5]: https://curl.haxx.se/libcurl/c/CURLOPT_FAILONERROR.html
> [6]: https://curl.haxx.se/libcurl/c/CURLINFO_RESPONSE_CODE.html
Thanks again; this list is terrific (and often entertaining when I
DON'T have a question).
Dave
/dps
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-03-23