176
117

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

curlコマンドでHTTPヘッダを扱うレシピ

Last updated at Posted at 2015-07-06

HEAD リクエストする

HTTP ヘッダだけ要求してボディは要求しない HEAD リクエストを送るには、 -I / --head を使う。

$ curl -I http://example.com/

レスポンスヘッダも一緒に見る

-i / --include を使う。

$ curl -i http://example.com/

リクエストヘッダを指定する

-H / --header を使う。よく使いそうな User-Agent (-A / --user-agent), Referer (-e / --referer), Cookie (-b / --cookie) にはそれぞれ専用のオプションがある。

$ curl -H 'Host:example.com.' http://93.184.216.34/

下記のように複数指定も可能。

$ curl -H 'Host:example.com.' -H 'Content-Type:text/xml' http://93.184.216.34/
176
117
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
176
117

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?