[Server & Network General] curl/wget で HTTP Header を確認する方法

例えば、mod_deflateでコンテンツが圧縮されているかを確認する。

## HTTP Header 情報のみを取得する

“`prettyprinted
% wget -S –spider http://example.com/
“`

“`prettyprinted
% curl -I http://example.com/
“`

> * [HTTPのページのヘッダ情報だけ取得する curl/wgetコマンド – それマグで!](http://takuya-1st.hatenablog.jp/entry/20110202/1296635084)

“`prettyprinted
% curl -I https://www.d-wood.com/
HTTP/1.1 200 OK
Date: Tue, 10 Dec 2013 07:41:34 GMT
Server: Apache
Last-Modified: Sat, 07 Dec 2013 18:10:57 GMT
ETag: “808f0f-7682-4ecf5af2dce40”
Accept-Ranges: bytes
Content-Length: 30338
Cache-Control: max-age=300, must-revalidate
Expires: Tue, 10 Dec 2013 07:46:34 GMT
Vary: Accept-Encoding,Cookie
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=UTF-8
“`

## オプション

実際に利用する場合は、オプションを追加して使うことになると思う。

> * [shell – wgetでリファラつけたりHostヘッダつけたりbasic認証突破したり – Qiita [キータ]](http://qiita.com/tak_0x00/items/edebe425a626e7a5c5d4)

“`bash
wget http://test.example.com –header=’Host: example.com’ –header=’Referer: http://www.example.com’ –user=myuser –password=mypassword
“`

> * [curlのオプション勉強したのでまとめ – うまい棒blog](http://d.hatena.ne.jp/hogem/20091122/1258863440)

“`bash
curl –user username:password http://example.com/
“`

> * [cURL – Manual (マニュアル日本語訳)](http://www.hcn.zaq.ne.jp/___/unix/curl_manual.html)

## gzip圧縮されたコンテンツを取得する

例えば、mod_deflateでコンテンツが圧縮されているかを確認する。

“`prettyprinted
% curl -H “Accept-Encoding:gzip,deflate” https://www.d-wood.com/ > d-wood.html.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6637 100 6637 0 0 14395 0 –:–:– –:–:– –:–:– 75420
“`

6637 byte

“`prettyprinted
% curl https://www.d-wood.com/ > d-wood.html
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 30589 100 30589 0 0 59733 0 –:–:– –:–:– –:–:– 208k
“`

30589 byte

> * [wgetやcurlでgzip圧縮されたコンテンツを取得する – ’ ー ’](http://mgng.aws.af.cm/556)