curl usage

来源:互联网 发布:超级账本 java 编辑:程序博客网 时间:2024/06/01 09:56
-i, --include              (HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more... -I, --head              (HTTP/FTP/FILE)  Fetch  the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on a FTP              or FILE file, curl displays the file size and last modification time only.


Usage: -i

>curl http://baidu.com<html><meta http-equiv="refresh" content="0;url=http://www.baidu.com/"></html>

We can also ask curl to provide more information about the response, for example we can let it display all response headers by using the-i switch:

>curl -i http://baidu.comHTTP/1.1 200 OKDate: Thu, 29 Aug 2013 05:43:17 GMTServer: ApacheCache-Control: max-age=86400Expires: Fri, 30 Aug 2013 05:43:17 GMTLast-Modified: Tue, 12 Jan 2010 13:48:00 GMTETag: "51-4b4c7d90"Accept-Ranges: bytesContent-Length: 81Connection: Keep-AliveContent-Type: text/html<html><meta http-equiv="refresh" content="0;url=http://www.baidu.com/"></html>


Usage: -I

>curl -I http://baidu.comHTTP/1.1 200 OKDate: Thu, 29 Aug 2013 05:45:59 GMTServer: ApacheCache-Control: max-age=86400Expires: Fri, 30 Aug 2013 05:45:59 GMTLast-Modified: Tue, 12 Jan 2010 13:48:00 GMTETag: "51-4b4c7d90"Accept-Ranges: bytesContent-Length: 81Connection: Keep-AliveContent-Type: text/html

Part II

       -v, --verbose              Makes the fetching more verbose/talkative. Mostly useful for debugging. A line starting with ’>’ means "header data" sent by curl, ’<’ means "header data" received              by curl that is hidden in normal cases, and a line starting with ’*’ means additional info provided by curl.              Note that if you only want HTTP headers in the output, -i, --include might be the option you’re looking for.              If you think this option still doesn’t give you enough details, consider using --trace or --trace-ascii instead.              This option overrides previous uses of --trace-ascii or --trace.              Use -s, --silent to make curl quiet.

Usage: -v

This command will make curl output a lot of additional information about the whole communication:


>curl -v http://localhost:8080/myapp/myresource* About to connect() to localhost port 8080 (#0)*   Trying 127.0.0.1... connected* Connected to localhost (127.0.0.1) port 8080 (#0)> GET /myapp/myresource HTTP/1.1> User-Agent: curl/7.21.7 (x86_64-unknown-linux-gnu) libcurl/7.21.7 OpenSSL/0.9.8o zlib/1.2.3 libidn/1.18 libssh2/1.4.2> Host: localhost:8080> Accept: */*>< HTTP/1.1 200 OK< Content-Type: text/plain< Date: Thu, 29 Aug 2013 06:05:53 GMT< Content-Length: 7<* Connection #0 to host localhost left intact* Closing connection #0Got it!sonora.peking.corp.yahoo.com: /home/zhishan/yahoo/cmm_daily/qe/data>curl -v http://baidu.com* About to connect() to baidu.com port 80 (#0)*   Trying 220.181.111.86... connected* Connected to baidu.com (220.181.111.86) port 80 (#0)> GET / HTTP/1.1> User-Agent: curl/7.21.7 (x86_64-unknown-linux-gnu) libcurl/7.21.7 OpenSSL/0.9.8o zlib/1.2.3 libidn/1.18 libssh2/1.4.2> Host: baidu.com> Accept: */*>< HTTP/1.1 200 OK< Date: Thu, 29 Aug 2013 06:07:10 GMT< Server: Apache< Cache-Control: max-age=86400< Expires: Fri, 30 Aug 2013 06:07:10 GMT< Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT< ETag: "51-4b4c7d90"< Accept-Ranges: bytes< Content-Length: 81< Connection: Keep-Alive< Content-Type: text/html<<html><meta http-equiv="refresh" content="0;url=http://www.baidu.com/"></html>* Connection #0 to host baidu.com left intact* Closing connection #0

Link: http://curl.haxx.se/



原创粉丝点击