How to display request headers with command line curl

后端 未结 9 738
一整个雨季
一整个雨季 2020-11-28 17:19

Command line curl can display response header by using -D option, but I want to see what request header it is sending. How can I do that?

9条回答
  •  情话喂你
    2020-11-28 17:51

    curl's -v or --verbose option shows the HTTP request headers, among other things. Here is some sample output:

    $ curl -v http://google.com/
    * About to connect() to google.com port 80 (#0)
    *   Trying 66.102.7.104... connected
    * Connected to google.com (66.102.7.104) port 80 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.16.4 (i386-apple-darwin9.0) libcurl/7.16.4 OpenSSL/0.9.7l zlib/1.2.3
    > Host: google.com
    > Accept: */*
    > 
    < HTTP/1.1 301 Moved Permanently
    < Location: http://www.google.com/
    < Content-Type: text/html; charset=UTF-8
    < Date: Thu, 15 Jul 2010 06:06:52 GMT
    < Expires: Sat, 14 Aug 2010 06:06:52 GMT
    < Cache-Control: public, max-age=2592000
    < Server: gws
    < Content-Length: 219
    < X-XSS-Protection: 1; mode=block
    < 
    
    301 Moved
    

    301 Moved

    The document has moved here. * Connection #0 to host google.com left intact * Closing connection #0

提交回复
热议问题