资源在浏览器上响应很好,但是curl是空的

时间:2014-05-29 17:46:06

标签: curl nginx

我正在向http://mydomain.com/api/company?keyword=demo发出GET请求,并且在浏览器上,它会工作并返回一个对象数组。以下是Chrome开发工具网络标签上显示的信息:

Remote Address:10.10.0.245:80
Request URL:http://mydomain.com/api/company?keyword=demo
Request Method:GET
Status Code:200 OK

Request Headers
    GET /api/company?keyword=demo HTTP/1.1
    Host: mydomain.com
    Connection: keep-alive
    Cache-Control: max-age=0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-US,en;q=0.8,es;q=0.6
    Cookie: optimizelyEndUserId=oeu1399053750186r0.30155641376040876; km_ai=xMfdodCdX6yXGrAlt3hWVxIotNg%3D; km_lv=x; __gads=ID=69f17ebdd35fb788:T=1399063348:S=ALNI_MZOemXyLuZVqfUnQNGa_HNAB9phbQ; aic_s3=5366b00d4170e2b1358b457b; km_uq=; optimizelySegments=%7B%22536810235%22%3A%22false%22%2C%22538650221%22%3A%22direct%22%2C%22548110140%22%3A%22gc%22%7D; optimizelyBuckets=%7B%7D; PHPSESSID=mq3vnkdqt69iki8vq1vb7aiah6; __atuvc=2%7C21%2C7%7C22; aic_s3=5366b00d4170e2b1358b457b
    Query String Parametersview parsed
    keyword=demo
Response Headers
    HTTP/1.1 200 OK
    Server: nginx/1.2.1
    Date: Thu, 29 May 2014 17:41:35 GMT
    Content-Type: text/html
    Transfer-Encoding: chunked
    Connection: close
    X-Powered-By: PHP/5.4.4-14+deb7u7
    Access-Control-Allow-Origin: *
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Content-Encoding: gzip

但是,当我使用curl -v http://mydomain.com/api/company?keyword=demo发出请求时,我得到一个空响应:

* Adding handle: conn: 0x7fa30c008c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fa30c008c00) send_pipe: 1, recv_pipe: 0
* About to connect() to mydomain.com port 80 (#0)
*   Trying 10.10.0.245...
* Connected to mydomain.com (10.10.0.245) port 80 (#0)
> GET /api/company?keywordrd=demo HTTP/1.1
> User-Agent: curl/7.30.0
> Host: mydomain.com
> Accept: */*
> 
< HTTP/1.1 200 OK
* Server nginx/1.2.1 is not blacklisted
< Server: nginx/1.2.1
< Date: Thu, 29 May 2014 17:44:22 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: close
< X-Powered-By: PHP/5.4.4-14+deb7u7
< Access-Control-Allow-Origin: *
< Set-Cookie: PHPSESSID=k98a20a34eosum2vjojicudgo3; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Set-Cookie: aic_s3=538771f6f8c312fe0c8b45af; expires=Wed, 23-Apr-2059 11:28:44 GMT; path=/; domain=.mydomain.com
< 
* Closing connection 0

这是什么原因?

0 个答案:

没有答案