curl 一样的请求返回的数据却不一样

2018-11-29 10:34:35 +08:00
 sgq1128

本地的 curl

curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy

服务器上的 curl

curl 7.62.0 (x86_64-redhat-linux-gnu) libcurl/7.62.0 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.15.0 libssh2/1.8.0 nghttp2/1.6.0
Release-Date: 2018-10-31
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy Metalink 

本地 curl 高德搜索 POI ( key 这里就不放出来了,引号里的内容百分百一致) 命令行

curl -v 'https://restapi.amap.com/v3/place/text?keywords=宋都如意春江&city=hangzhou&output=JSON&offset=1&page=1&key=高德秘钥&extensions=all'

本地返回

*   Trying 106.11.249.5...
* TCP_NODELAY set
* Connected to restapi.amap.com (106.11.249.5) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=CN; ST=ZheJiang; L=HangZhou; O=Alibaba (China) Technology Co., Ltd.; CN=*.amap.com
*  start date: Jul 16 02:51:07 2018 GMT
*  expire date: Jul 17 02:51:07 2019 GMT
*  subjectAltName: host "restapi.amap.com" matched cert's "*.amap.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Organization Validation CA - SHA256 - G2
*  SSL certificate verify ok.
> GET /v3/place/text?keywords=宋都如意春江&city=hangzhou&output=JSON&offset=1&page=1&key=&extensions=all HTTP/1.1
> Host: restapi.amap.com
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Tengine
< Date: Thu, 29 Nov 2018 02:29:00 GMT
< Content-Type: application/json;charset=UTF-8
< Content-Length: 940
< Connection: close
< Vary: Accept-Encoding
< X-Powered-By: ring/1.0.0
< gsid: c7e2cc15077776ba592e1dff2a384c5a
< sc: 0.099
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: *
< Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,key,x-biz,x-info,platinfo,encr,enginever,gzipped,poiid
< 
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
{"status":"1","count":"2","info":"OK","infocode":"10000","suggestion":{"keywords":[],"cities":[]},"pois":[{"id":"B0FFJ0DVH0","parent":[],"name":"宋都·如意春江(建设中)","tag":[],"type":"商务住宅;商务住宅相关;商务住宅相关","typecode":"120000","biz_type":[],"address":"江滨东大道","location":"120.032125,30.081818","tel":"0571-63129999","postcode":[],"website":[],"email":[],"pcode":"330000","pname":"浙江省","citycode":"0571","cityname":"杭州市","adcode":"330111","adname":"富阳区","importance":[],"shopid":[],"shopinfo":"0","poiweight":[],"gridcode":"4520009221","distance":[],"navi_poiid":[],"entr_location":[],"business_area":"东洲","exit_location":[],"match":"0","recommend":"3","timestamp":[],"alias":[],"indoor_map":"0","indoor_data":{"cpid":[],"floor":[],"truefloor":[],"cmsid":[]},"groupbuy_num":"0","discount_num":"0","biz_ext":{"rating":[],"cost":[]},"event":[],"children":[],"photos":[]}]}

服务器上返回

*   Trying 106.11.6.22...
* TCP_NODELAY set
* Connected to restapi.amap.com (106.11.6.22) port 443 (#0)
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* NPN, negotiated HTTP1.1
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Next protocol (67):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
*  subject: C=CN; ST=ZheJiang; L=HangZhou; O=Alibaba (China) Technology Co., Ltd.; CN=*.amap.com
*  start date: Jul 16 02:51:07 2018 GMT
*  expire date: Jul 17 02:51:07 2019 GMT
*  subjectAltName: host "restapi.amap.com" matched cert's "*.amap.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Organization Validation CA - SHA256 - G2
*  SSL certificate verify ok.
> GET /v3/place/text?keywords=宋都如意春江&city=hangzhou&output=JSON&offset=1&page=1&key=&extensions=all HTTP/1.1
> Host: restapi.amap.com
> User-Agent: curl/7.62.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Tengine
< Date: Thu, 29 Nov 2018 02:31:12 GMT
< Content-Type: application/json;charset=UTF-8
< Content-Length: 1045
< Connection: close
< Vary: Accept-Encoding
< X-Powered-By: ring/1.0.0
< gsid: 05f40ec7394c3ad27ad5d687928cdef3
< sc: 0.105
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: *
< Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,key,x-biz,x-info,platinfo,encr,enginever,gzipped,poiid
< 
{"status":"1","count":"275","info":"OK","infocode":"10000","suggestion":{"keywords":[],"cities":[]},"pois":[{"id":"B023B08Z1D","parent":[],"name":"春江名苑","tag":[],"type":"商务住宅;住宅区;住宅小区","typecode":"120302","biz_type":[],"address":"望江东路与富春路交叉口","location":"120.192263,30.227176","tel":[],"postcode":[],"website":[],"email":[],"pcode":"330000","pname":"浙江省","citycode":"0571","cityname":"杭州市","adcode":"330102","adname":"上城区","importance":[],"shopid":[],"shopinfo":"0","poiweight":[],"gridcode":"4520217501","distance":"2360","navi_poiid":"H51F022002_96256","entr_location":"120.193053,30.227074","business_area":[],"exit_location":[],"match":"0","recommend":"0","timestamp":[],"alias":[],"indoor_map":"0","indoor_data":{"cpid":[],"floor":[],"truefloor":[],"cmsid":[]},"groupbuy_num":"0","discount_num":"0","biz_ext":{"rating":[],"cost":"57259.00"},"event":[],"children":[],"photos":[{"title":[],"url":"http://store.is.autonavi.com/showpic/eebdbfb5a20d7088d* Closing connection 0
* TLSv1.2 (OUT), TLS alert, close notify (256):
3e882c41b7fc3bc"}]}]}

可以看到返回的内容不一致,本地返回的才是正确的,服务器上之前升级到 h2 了,openssl 用的 OpenSSL/1.0.1e,有大佬知道为什么嘛

1740 次点击
所在节点    问与答
5 条回复
hcymk2
2018-11-29 10:47:53 +08:00
每次都是一样的结果么?
sgq1128
2018-11-29 10:51:03 +08:00
@hcymk2 服务器返回的每次都一样的
lululau
2018-11-29 10:53:18 +08:00
怎么看出来一样的,连服务端地址都不一样
sgq1128
2018-11-29 11:02:35 +08:00
lululau
2018-11-29 12:12:30 +08:00
@sgq1128 对啊,先换成同一个 IP 试试啊

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/512622

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX