博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

HTTP解读

Posted on 2017-07-22 15:00  开飞机的贝塔  阅读(114)  评论(0编辑  收藏  举报

使用Telnet工具访问web资源

Windows中没有telnet这一工具,下面在Linux下演示:

telnet www.baidu.com 80

Trying 61.135.169.125...
Connected to www.baidu.com.
Escape character is '^]'.
GET / HTTP/1.1 //请求首行

HTTP/1.1 302 Moved Temporarily //响应首行
Date: Sat, 22 Jul 2017 06:47:00 GMT //响应首部
Content-Type: text/html
Content-Length: 215
Connection: Keep-Alive
Location: http://www.baidu.com/search/error.html
Server: BWS/1.1
X-UA-Compatible: IE=Edge,chrome=1
BDPAGETYPE: 3
Set-Cookie: BDSVRTM=0; path=/

<html> //响应主体(首部和主体之间用空行隔开)
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>pr-nginx_1-0-345_BRANCH Branch
Time : Wed Jun 28 10:14:05 CST 2017</center>
</body>
</html>

说明:输入完请求首行之后要按2次回车

为了避免安全字符集的限制,通过转义的方式来表示不安全的字符。

%7E 表示-

%20 表示空格

%25 表示%