简单的WebServer细节

来源:互联网 发布:linux安装oracle11gr2 编辑:程序博客网 时间:2024/04/28 19:47

1.请求静态网页

Client Request:

GET / HTTP/1.1Host: 192.168.10.120:8000Connection: keep-aliveCache-Control: max-age=0User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.95 Safari/537.4Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding: gzip,deflate,sdchAccept-Language: zh-CN,zh;q=0.8Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3#########server回应HTTP/1.0 200 OKServer: SimpleHTTP/0.6 Python/2.7.3Date: Mon, 13 May 2013 15:32:29 GMTContent-type: text/html; charset=mbcsContent-Length: 366<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><title>Directory listing for /</title><body><h2>Directory listing for /</h2><hr><ul><li><a href="1.ps">1.ps</a><li><a href="2.wps">2.wps</a><li><a href="23_lan/">23_lan/</a><li><a href="3.txt">3.txt</a><li><a href="cvtest/">cvtest/</a><li><a href="test1/">test1/</a></ul><hr></body></html>

2.请求传输文件

GET /3.txt HTTP/1.1Host: 192.168.10.120:8000Connection: keep-aliveUser-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.95 Safari/537.4Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Referer: http://192.168.10.120:8000/Accept-Encoding: gzip,deflate,sdchAccept-Language: zh-CN,zh;q=0.8Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3HTTP/1.0 200 OKServer: SimpleHTTP/0.6 Python/2.7.3Date: Mon, 13 May 2013 15:32:34 GMTContent-type: text/plainContent-Length: 516Last-Modified: Mon, 13 May 2013 15:31:54 GMT(1).................................................................................................(2)....................................................j.........................j............................................................................................................................ ..............................................................................................................................................................................................................[2]

3.传输404

GET /favicon.ico HTTP/1.1Host: 192.168.10.120:8000Connection: keep-aliveAccept: */*User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.95 Safari/537.4Accept-Encoding: gzip,deflate,sdchAccept-Language: zh-CN,zh;q=0.8Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3HTTP/1.0 404 File not foundServer: SimpleHTTP/0.6 Python/2.7.3Date: Mon, 13 May 2013 15:32:32 GMTContent-Type: text/htmlConnection: close<head><title>Error response</title></head><body><h1>Error response</h1><p>Error code 404.<p>Message: File not found.<p>Error code explanation: 404 = Nothing matches the given URI.</body>