上传表单输入 Post方法: 口Web页通常包含表单输 入 URL方法 T输入的表单内容放在报使用GET方法 文体中上传到服务器 输入内容放在请求行的 URL字段中上传,如: Www.SomesIte.com/animalsearch?monkeysbanana Application Layer 27
2: Application Layer 27 上传表单输入 Post 方法: Web页通常包含表单输 入 输入的表单内容放在报 文体中上传到服务器 URL 方法: 使用 GET 方法 输入内容放在请求行的 URL字段中上传,如: www.somesite.com/animalsearch?monkeys&banana
HTTP方法 Http/1.0 Http/1.1 O GET 口GET,POST,HEAD O POST U PUT J HEAD 将文件放在报文实体 要求服务器不返回对 中,传到URL字段指 象,只用一个报文头 定的路径 响应(实体为空),口 DELETE 常用于故障跟踪。 删除URL字段指示的 文件 Application Lo
2: Application Layer 28 HTTP方法 HTTP/1.0 GET POST HEAD ❖ 要求服务器不返回对 象,只用一个报文头 响应(实体为空), 常用于故障跟踪。 HTTP/1.1 GET, POST, HEAD PUT ❖ 将文件放在报文实体 中,传到URL字段指 定的路径 DELETE ❖ 删除URL字段指示的 文件
HTTP响应报文 状态行 Http/1.1 200ok Connection: close Date: Thu, 06 Aug 1998 12: 00: 15GMT 首部行 Server: Apache/1.30(Unix) Last-Modified: Mon, 22 Jun 1998 Content-Length: 6821 Content-Type: text/html 数据,如请求的 data datadata data data HTML文件 2: Application Layer 29
2: Application Layer 29 HTTP 响应报文 HTTP/1.1 200 OK Connection: close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ... 状态行 首部行 数据,如请求的 HTML文件
HTTP响应状态代码 a few sample codes: 200oK go request succeeded, requested ob ject later in this message 301 Moved Permanently so requested object moved, new location specified later in this message location 400 Bad Request , o request message not understood by server 404 Not Found g requested document not found on this server 505 Http Version Not Supported Application Layer 30
2: Application Layer 30 HTTP 响应状态代码 200 OK ❖ request succeeded, requested object later in this message 301 Moved Permanently ❖ requested object moved, new location specified later in this message (Location:) 400 Bad Request ❖ request message not understood by server 404 Not Found ❖ requested document not found on this server 505 HTTP Version Not Supported A few sample codes:
Trying out Http(cLienT side for yourself 1. Telnet to your favorite web server telnet cis poly. edu 80 Opens TCP connection to port 80 default Http server port)at cis poly edu Anything typed is sent to port 80 at cispoly. edu 2. Type in a Get Http request Get/wRoss/http:/1.1 By typing this in (hit carriage Host: cis poly. edu return twice), you send this minimal(but complete) Get request to Http server 3.Lookatresponsemessagesentbyhttpserver 2: Application layer 31
2: Application Layer 31 Trying out HTTP (client side) for yourself 1. Telnet to your favorite Web server: Opens TCP connection to port 80 (default HTTP server port) at cis.poly.edu. Anything typed is sent to port 80 at cis.poly.edu telnet cis.poly.edu 80 2. Type in a GET HTTP request: GET /~ross/ HTTP/1.1 Host: cis.poly.edu By typing this in (hit carriage return twice), you send this minimal (but complete) GET request to HTTP server 3. Look at response message sent by HTTP server!