简单的WebServer细节

1.请求静态网页

Client Request:

GET / HTTP/1.1

Host: 192.168.10.120:8000

Connection: keep-alive

Cache-Control: max-age=0

User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.95 Safari/537.4

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Encoding: gzip,deflate,sdch

Accept-Language: zh-CN,zh;q=0.8

Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3


#########server回应
HTTP/1.0 200 OK

Server: SimpleHTTP/0.6 Python/2.7.3

Date: Mon, 13 May 2013 15:32:29 GMT

Content-type: text/html; charset=mbcs

Content-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.1

Host: 192.168.10.120:8000

Connection: keep-alive

User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.95 Safari/537.4

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Referer: http://192.168.10.120:8000/

Accept-Encoding: gzip,deflate,sdch

Accept-Language: zh-CN,zh;q=0.8

Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3



HTTP/1.0 200 OK

Server: SimpleHTTP/0.6 Python/2.7.3

Date: Mon, 13 May 2013 15:32:34 GMT

Content-type: text/plain

Content-Length: 516

Last-Modified: Mon, 13 May 2013 15:31:54 GMT



(1).................................................................................................(2)....................................................j.........................j............................................................................................................................ ..............................................................................................................................................................................................................[2]

3.传输404

GET /favicon.ico HTTP/1.1

Host: 192.168.10.120:8000

Connection: keep-alive

Accept: */*

User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.95 Safari/537.4

Accept-Encoding: gzip,deflate,sdch

Accept-Language: zh-CN,zh;q=0.8

Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3



HTTP/1.0 404 File not found

Server: SimpleHTTP/0.6 Python/2.7.3

Date: Mon, 13 May 2013 15:32:32 GMT

Content-Type: text/html

Connection: 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>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值