How to display request headers with command line curl

后端 未结 9 709
一整个雨季
一整个雨季 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:58

    A popular answer for displaying response headers, but OP asked about request headers.

    curl -s -D - -o /dev/null http://example.com
    
    • -s : Avoid showing progress bar
    • -D - : Dump headers to a file, but - sends it to stdout
    • -o /dev/null : Ignore response body

    This is better than -I as it doesn't send a HEAD request, which can produce different results.

    It's better than -v because you don't need so many hacks to un-verbose it.

提交回复
热议问题