telnetコマンドによるHTTP通信の例

 次に、telnetコマンドをWebクライアントに見立てて、Linux(Fedora Core)で動作しているWebサーバ「Apache」に対してGETコマンドを使用してHTMLファイル「index.html」を要求した実行結果を示す。telnetコマンドの最後の引数に「80」を指定し、80番ポートに接続していることに注意。

$ telnet hula 80<E> ←ホスト「hura」の80番ポートに接続
Trying 192.168.1.33...
Connected to hula.home.domain(192.168.1.33).
Escape character is '^]'.
----------------------------------------------------------------------
GET /index.html HTTP/1.1<E> ←リクエストライン
host:mars.peachpress.co.jp<E> ←ヘッダ
<E> ←空行
----------------------------------------------------------------------
HTTP/1.1 200 OK ←ステータスライン
----------------------------------------------------------------------
Date : Wed, 08 Nov 2006 05:22:35 GMT
Server : Apache/2.2.3(Fedora)
Last-Modified : Fri, 29 Sep 2006 14:57:49 GMT
ETag : "1979a1-127-3d29b840"
Accept-Ranges : bytes
Content-Length : 295
Connection : close
Content^Type : text/html
----------------------------------------------------------------------
<E> ←空行
----------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>Sample</title>
</head>
<body bgcolor="#FFFFFF">
<h1>Hello</h1>
</body>
</html>
----------------------------------------------------------------------
Connection closed by foreign host. ←切断
最終更新:2007年06月05日 17:56