cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl-library Digest, Vol 129, Issue 46

From: supercaowei <supercaowei1989_at_163.com>
Date: Mon, 30 May 2016 14:02:43 +0800

Thank you all for the replies.
Yes, I set both CURLOPT_HEADERFUNCTION and CURLOPT_WRITEFUNCTION.
Here, I will paste the logs of success situation and failure situation printed by curl.
For the policy of privacy of my corp, I have to hide the host addresses as {app server} and {app server}. The IP addresses are also fake.
------------------------------------------------------------------------------------------------------
Success situation :
* Connection #5 to {app server} left intact
* Found bundle for {app server}: 0x16b6fad0
* Re-using existing connection! (#5) with {app server}
* Connected to {app server} (223.232.179.5) port 443 (#5)
> GET /live/thirdpartycallback/yixinPc HTTP/1.1
Host: {app server}
Accept: */*
YX-PN: yxmc
YX-VSN: 1
YX-CTT: cQtpv30f3XYNreTwPp1ExunUZhA1szHRhcv01X1YQ2489wRDalhw2sDPsCbwannq
Content-Type: application/octet-stream
User-Agent: YiXin/1861
openid: MzQ4NjkwMDc=
yx_cookie: Kj3x2jmhI1yy7oSS1OO4cQ==

< HTTP/1.1 302 Found
* Server nginx is not blacklisted
< Server: nginx
< Date: Fri, 27 May 2016 08:11:49 GMT
< Content-Length: 0
< Connection: keep-alive
< Location: http://{authorize server}/connect/oauth2/authorize?appid=46c7ca7b186645f4b1085371872d211e&redirect_uri=https%3A%2F%2F{app server}%2Flive%2Fthirdpartycallback%2FyixinPc%3Fsource%3DyixinPc&response_type=code&scope=snsapi_base&state=1#yixin_redirect
< Content-Language: en-US
<
* Connection #6 to host {app server} left intact
* Issue another request to this URL: 'http://{authorize server}/connect/oauth2/authorize?appid=46c7ca7b186645f4b1085371872d211e&redirect_uri=https%3A%2F%2F{app server}%2Flive%2Fthirdpartycallback%2FyixinPc%3Fsource%3DyixinPc&response_type=code&scope=snsapi_base&state=1#yixin_redirect'
* Hostname was NOT found in DNS cache
* Trying 223.232.178.135...
* Connected to {authorize server} (223.232.178.135) port 80 (#7)
> GET /connect/oauth2/authorize?appid=46c7ca7b186645f4b1085371872d211e&redirect_uri=https%3A%2F%2F{app server}%2Flive%2Fthirdpartycallback%2FyixinPc%3Fsource%3DyixinPc&response_type=code&scope=snsapi_base&state=1 HTTP/1.1
Host: {authorize server}
Accept: */*
YX-PN: yxmc
YX-VSN: 1
YX-CTT: cQtpv30f3XYNreTwPp1ExmGpDwUT6VUvTLQA0D+QQCI89wRDalhw2sDPsCbwannq
Content-Type: application/octet-stream
User-Agent: YiXin/1861
openid: MzQ4NjkwMDc=
yx_cookie: b2YZHyOciRSDOhsMVvNkYg==

< HTTP/1.1 302 Found
* Server nginx/1.2.1 is not blacklisted
< Server: nginx/1.2.1
< Date: Fri, 27 May 2016 08:11:50 GMT
< Content-Length: 0
< Connection: keep-alive
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: no-store
< Location: https://{app server}/live/thirdpartycallback/yixinPc?source=yixinPc&code=N3s3UD&state=1
< Content-Language: en-US
<
------------------------------------------------------------------------------------------------------

Failure situation:
* Connection #5 to {app server} left intact
* Found bundle for {app server}: 0x16b6fad0
* Re-using existing connection! (#5) with {app server}
* Connected to {app server} (223.232.179.5) port 443 (#5)
> GET /live/thirdpartycallback/yixinPc HTTP/1.1
Host: {app server}
Accept: */*
YX-PN: yxmc
YX-VSN: 1
YX-CTT: cQtpv30f3XYNreTwPp1ExunUZhA1szHRhcv01X1YQ2489wRDalhw2sDPsCbwannq
Content-Type: application/octet-stream
User-Agent: YiXin/1861
openid: MzQ4NjkwMDc=
yx_cookie: Kj3x2jmhI1yy7oSS1OO4cQ==

< HTTP/1.1 302 Found
* Server nginx is not blacklisted
< Server: nginx
< Date: Sat, 28 May 2016 03:58:34 GMT
< Content-Length: 0
< Connection: keep-alive
< Location: http://{authorize server}/connect/oauth2/authorize?appid=46c7ca7b186645f4b1085371872d211e&redirect_uri=https%3A%2F%{app server}%2Flive%2Fthirdpartycallback%2FyixinPc%3Fsource%3DyixinPc&response_type=code&scope=snsapi_base&state=1#yixin_redirect
< Content-Language: en-US
<
* Connection #5 to host {app server} left intact
* Issue another request to this URL: 'http://{authorize server}/connect/oauth2/authorize?appid=46c7ca7b186645f4b1085371872d211e&redirect_uri=https%3A%2F%2F{app server}%2Flive%2Fthirdpartycallback%2FyixinPc%3Fsource%3DyixinPc&response_type=code&scope=snsapi_base&state=1#yixin_redirect'
* Hostname was NOT found in DNS cache
* Closing connection 8
* Found bundle for host {app server}: 0x16b6fad0
* Connection 5 seems to be dead!
* Closing connection 5
* Hostname was NOT found in DNS cache
* Trying 223.232.179.5...
* Connected to {app server} (223.232.179.5) port 443 (#9)
* SSL connection using TLSv1.0 / DHE-RSA-AES256-SHA
* Server certificate:
* subject: C=CN; ST=Zhejiang; L=Hangzhou; O=xxx Co., Ltd; OU=MAIL Dept.; CN=*.xxx.com
* start date: 2015-10-14 00:00:00 GMT
* expire date: 2017-12-30 23:59:59 GMT
* issuer: C=US; O=GeoTrust Inc.; CN=GeoTrust SSL CA - G3
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /fgadmin/checkLogin HTTP/1.1
Host: {app server}
Accept: */*
YX-PN: yxmc
YX-VSN: 1
YX-CTT: cQtpv30f3XYNreTwPp1ExunUZhA1szHRNQnugEykikU89wRDalhw2sDPsCbwannq
Content-Type: application/octet-stream
User-Agent: YiXin/1861
openid: MzQ4NjkwMDc=
yx_cookie: Kj3x2jmhI1yy7oSS1OO4cQ==
------------------------------------------------------------------------------------------------------

I sent a http api "/live/thirdpartycallback/yixinPc" and got an auth url. Then I tried the url to do the authentication.
In the success situation, the actual auth api was right. But in the failure situation, it turned out to be "/fgadmin/checkLogin". Did it make sense?
The difference of my code between success situation and failure situation, is whether to redirect stderr to the console, like what I said in the former email. I don't change the local certificate.
If you claim that there is something wrong with the certificate or the server, why can the success situation occur?

By the way, I have another discovery. In the success situation, stderr was redirected to the console with following code:
freopen("CONOUT$","w+t", stderr);
If I change the file opening mode to "wt" (forbid reading from stderr), the situation will change to failure. How does this affects?


2016-05-30

supercaowei



发件人:curl-library-request_at_cool.haxx.se
发送时间:2016-05-29 18:00
主题:curl-library Digest, Vol 129, Issue 46
收件人:"curl-library"<curl-library_at_cool.haxx.se>
抄送:

Send curl-library mailing list submissions to
    curl-library_at_cool.haxx.se

To subscribe or unsubscribe via the World Wide Web, visit
    http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
or, via email, send a message with subject or body 'help' to
    curl-library-request_at_cool.haxx.se

You can reach the person managing the list at
    curl-library-owner_at_cool.haxx.se

When replying, please edit your Subject line so it is more specific
than "Re: Contents of curl-library digest..."


Today's Topics:

   1. Re: A weird problem in the cURL library (Daniel Stenberg)
   2. Re: A weird problem in the cURL library (Daniel Stenberg)
   3. Re: Getting files from SFTP is slower at newer versions
      (Daniel Stenberg)
   4. Re: CURLE_OPERATION_TIMEDOUT (vs) CURLE_COULDNT_CONNECT
      (Daniel Stenberg)
   5. Re: Getting files from SFTP is slower at newer versions
      (Moti Avrahami)


----------------------------------------------------------------------

Message: 1
Date: Sat, 28 May 2016 16:27:39 +0200 (CEST)
From: Daniel Stenberg <daniel_at_haxx.se>
To: libcurl development <curl-library_at_cool.haxx.se>
Subject: Re: A weird problem in the cURL library
Message-ID: <alpine.DEB.2.20.1605281624320.27045_at_tvnag.unkk.fr>
Content-Type: text/plain; format=flowed; charset=US-ASCII

On Fri, 27 May 2016, supercaowei wrote:

> Hope I will not spare you too much time. I am a Chinese programmer. Recently
> I was using the open source library cURL, which was written by you. I have
> got a problem which really puzzled me. I post an oauth https request
> (actually, the method is "get") , but get nothing back.

So the write callback was never invoked at all? If so, can you tell us more
about which libcurl version you're using and show us how a full HTTP response
from the server looks like? (edit out sensitive info before sending anything)

Was it the response body you want or just the headers? If headers, do you have
a WRITEFUNCTION callback set?

--

  / daniel.haxx.se


------------------------------

Message: 2
Date: Sat, 28 May 2016 23:47:13 +0200 (CEST)
From: Daniel Stenberg <daniel_at_haxx.se>
To: libcurl development <curl-library_at_cool.haxx.se>
Subject: Re: A weird problem in the cURL library
Message-ID: <alpine.DEB.2.20.1605282346440.27045_at_tvnag.unkk.fr>
Content-Type: text/plain; charset=US-ASCII; format=flowed

On Sat, 28 May 2016, Daniel Stenberg wrote:

> Was it the response body you want or just the headers? If headers, do you
> have a WRITEFUNCTION callback set?

Oops, I meant to ask about CURLOPT_HEADERFUNCTION. The header callback.

--

  / daniel.haxx.se

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-30