telnet でいろいろ確認
概要
telnetでいろいろな確認を行うための手法。
手順
HTTP
基本のGET。
# telnet XXX.XXX.XXX.XXX 80 Trying XXX.XXX.XXX.XXX... Connected to XXX.XXX.XXX.XXX Escape character is '^]'. GET /index.html HTTP/1.0 ← リクエストを入力 ← 空行で改行
結果は以下。
HTTP/1.1 200 OK Date: Tue, 12 Aug 2008 13:55:53 GMT Server: Apache/X.X.X Last-Modified: Tue, 12 Aug 2008 13:55:39 GMT ETag: "XXXXXXXXXXXXXXXXX" Accept-Ranges: bytes Content-Length: XXX Connection: close Content-Type: text/html; charset=UTF-8 〜HTMLファイルの中身〜 Connection closed by foreign host.
HEADだと、HTTPヘッダのみ
HEAD / HTTP/1.0 ← リクエストを入力 ← 空行で改行 HTTP/1.1 200 OK Date: Tue, 12 Aug 2008 13:57:45 GMT ・・・略・・・ Content-Type: text/html; charset=UTF-8 Connection closed by foreign host.
HTTP1.1の場合はバーチャルホストのためにHostヘッダが必須。
GET /index.html HTTP/1.1 ← リクエストを入力 Host: www.example.com ← 空行で改行 HTTP/1.1 200 OK ・・・略・・・・ (Connection closed で切断されずそのまま)
Connection closedで切断されない場合はサーバ側でKeep-Aliveが有効になっている。 切断する場合は"Connection: Close"で明示的に切断する。
GET /index.html HTTP/1.1 ← リクエストを入力 Host: www.example.com Connection: Close ← 空行で改行 HTTP/1.1 200 OK ・・・略・・・・ Connection closed by foreign host. ← 切断された

