Message 例子
优质
小牛编辑
128浏览
2023-12-01
例子1 (Example 1)
HTTP请求从xnip.cn运行的Web服务器获取hello.htm页面。
客户要求
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.xnip.cn
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 (Example 2)
用于获取在xnip.cn上运行的Web服务器上不存在的t.html页面的HTTP请求。
客户要求
GET /<b>t.html</b> HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.xnip.cn
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 /t.html was not found on this server.</p>
</body>
</html>
例子3 (Example 3)
HTTP请求从xnip.cn运行的Web服务器获取hello.htm页面,但请求的HTTP版本不正确:
客户要求
GET /hello.htm <b>HTTP1</b>
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.xnip.cn
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 (Example 4)
HTTP请求将表单数据发布到在xnip.cn上运行的Web服务器上的process.cgi CGI页面。 服务器在将它们设置为cookie后返回传递的名称:
客户要求
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.xnip.cn
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=xnip.cn;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>