Filed under templates, internet
例如, 请求www.qq.com在命令行下, 输入:telnet www.qq.com 80
粘贴一下内容:
GET / HTTP/1.1
Host:www.qq.com
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0.1) Gecko/20100101 Firefox/8.0.1
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language:zh-cn,zh;q=0.5
Accept-Encoding:gzip, deflate
Accept-Charset:GB2312,utf-8;q=0.7,*;q=0.7
Connection:keep-alive
Cache-Control:max-age=0
正常情况下, 你会看到乱码.因为Accept-Encoding:gzip, deflate 指示:接收gzip压缩的二进制内容.命令行下是无法查看的.
退出telnet
再次在 命令行里输入: telnet www.qq.com 80
GET / HTTP/1.1
Host:www.qq.com
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0.1) Gecko/20100101 Firefox/8.0.1
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language:zh-cn,zh;q=0.5
Accept-Encoding:deflate
Accept-Charset:GB2312,utf-8;q=0.7,*;q=0.7
Connection:keep-alive
Cache-Control:max-age=0
模拟完成.
和浏览器接收到的一模一样.
普及:
在互联网七层协议
HTTP Application layer
TCP Transport layer
IP Network layer
数据链路层 Data link layer
物理层 Physical layer
里 IP TCP HTTP 是这个位置.
我们 的一个请求 是 和 远程服务器 建立TCP链接, 然后 使用HTTP协议, 发送一个请求REQUEST.
START LINE :
GET /tools.html HTTP/1.1
HTTP/1.1 200 OK
HEADER FIELD
User-agent: Mozilla/4.75 [en] (Win98; U)
Host: www.joes-hardware.com
Accept: text/html, image/gif, image/jpeg
Accept-language: en
Date: Sun, o1 Oct 2000 23:25:17 GMT
Server: Apache/1.3.11 BSafe-SSL/1.38 (Unix)
Last-modified: Tue, 04 Jul 2000 09:46:21 GMT
Content-length: 403
Content-type: text/html
BODY
<HTML>
<HEAD><TITLE>Joe’s Tools</TITLE></HEAD>
<BODY>
<H1>Tools Page</H1>
<H2>Hammers</H2>
<P>Joe’s Hardware Online has the largest selection of
hammers on the earth.</P>
<H2><A NAME=drills></A>Drills</H2>
<P>Joe’s Hardware has a complete line of cordless
and corded drills, as well as the latest in
plutonium-powered atomic drills, for those big
around the house jobs./<P>...
</BODY>
</HTML>
More »
- Erwin
- John Doe
- Naruto
- Shikamaru
- ABCD