
- HTTP 教程
- HTTP - 首頁
- HTTP - 概述
- HTTP - 引數
- HTTP - 訊息
- HTTP - 請求
- HTTP - 響應
- HTTP - 方法
- HTTP - 狀態程式碼
- HTTP - 頭欄位
- HTTP - 快取
- HTTP - URL 編碼
- HTTP - 安全
- HTTP - 訊息示例
- HTTP 有用資源
- HTTP - 快速指南
- HTTP - 有用資源
HTTP - 訊息示例
示例 1
HTTP 請求,從執行在 tutorialspoint.com 的 Web 伺服器中獲取 hello.htm 頁面。
客戶端請求
GET /hello.htm HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.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
HTTP 請求,從執行在 tutorialspoint.com 的 Web 伺服器中獲取不存在的 t.html 頁面。
客戶端請求
GET /t.html HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.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 /t.html was not found on this server.</p> </body> </html>
示例 3
HTTP 請求,從執行在 tutorialspoint.com 的 Web 伺服器中獲取 hello.htm 頁面,但是該請求使用錯誤的 HTTP 版本
客戶端請求
GET /hello.htm HTTP1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.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
HTTP 請求,將表單資料釋出到在執行在 tutorialspoint.com 的 Web 伺服器上的 CGI 頁面 process.cgi。伺服器在將這些資料設為 Cookie 後返回傳遞的名稱
客戶端請求
POST /cgi-bin/process.cgi HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.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=tutorialspoint.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>
廣告