Http-message-examples

提供:Dev Guides
移動先:案内検索

HTTP-メッセージの例

例1

_finddevguides.com_で実行されているWebサーバーから hello ページをフェッチするためのHTTPリクエスト。

クライアントリクエスト

GET/hello HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.finddevguides.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

サーバー応答

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed
<html>
   <body>

   <h1>Hello, World!</h1>

   </body>
</html>

例2

_finddevguides.com_で実行されているWebサーバーに存在しない tl ページをフェッチするためのHTTPリクエスト。

クライアントリクエスト

GET/tl HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.finddevguides.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

サーバー応答

HTTP/1.1 404 Not Found
Date: Sun, 18 Oct 2012 10:36:20 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 230
Content-Type: text/html; charset=iso-8859-1
Connection: Closed
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>

<head>
   <title>404 Not Found</title>
</head>

<body>
   <h1>Not Found</h1>
   <p>The requested URL/tl was not found on this server.</p>
</body>

</html>

実施例3

_finddevguides.com_で実行されているWebサーバーから hello ページをフェッチするためのHTTPリクエストですが、リクエストは正しくないHTTPバージョンで送信されます。

クライアントリクエスト

GET/hello HTTP1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.finddevguides.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

サーバー応答

HTTP/1.1 400 Bad Request
Date: Sun, 18 Oct 2012 10:36:20 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 230
Content-Type: text/html; charset=iso-8859-1
Connection: Closed
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>

<head>
   <title>400 Bad Request</title>
</head>

<body>
   <h1>Bad Request</h1>
   <p>Your browser sent a request that this server could not understand.<p>
   <p>The request line contained invalid characters following the protocol string.<p>
</body>

</html>

実施例4

_finddevguides.com_で実行されているWebサーバーの process.cgi CGIページにフォームデータをポストするためのHTTPリクエスト。 サーバーは、Cookieとして設定した後、渡された名前を返します。

クライアントリクエスト

POST/cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.finddevguides.com
Content-Type: text/xml; charset=utf-8
Content-Length: 60
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

first=Zara&last=Ali

サーバー応答

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 88
Set-Cookie: first=Zara,last=Ali;domain=finddevguides.com;Expires=Mon, 19-
Nov-2010 04:38:14 GMT;Path=/
Content-Type: text/html
Connection: Closed
<html>

<body>
   <h1>Hello Zara Ali</h1>
</body>

</html>