HTTP协议是学习JavaWEB开发的基石,不深入了解HTTP协议,就不能说掌握了WEB开发!
消息头:
l用于HTTP请求中的常用头
•Accept: text/html,image/*
•Accept-Charset: ISO-8859-1
•Accept-Encoding: gzip,compress
•Accept-Language: en-us,zh-cn
•Host: www.baidu.com
•If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT
•Referer: http://www.baidu.org/index.jsp
•User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
•Cookie
•Connection: close/Keep-Alive
•Date: Tue, 11 Jul 2000 18:23:51 GMT
http请求头:
Accept:这个头用于告诉服务器,浏览器支持哪些数据类型
Accept-Charset:这个头用于告诉服务器,浏览器采用的是哪种编码
Accept-Encoding:这个头用于告诉服务器,浏览器支持哪种数据压缩格式
Accept-Language:这个头用于告诉服务器,浏览器的语言环境
Host:这个头用于告诉服务器,浏览器想访问的主机名
If-Modified-Since:这个是和缓存相关的头,这个头用于告诉服务器,浏览器缓存资源的时间
Referer:这个头用于告诉服务器,浏览器是从哪个页面来的(可以防止盗链)
User-Agent: 用于告诉服务器,浏览器的机器环境
Cookie:浏览器通过cookie,可以带一些数据给服务器
-----------------------------------------------------------------------------
Http响应:
location: 这个头配合302使用,用于告诉浏览器去找哪个资源
Server:这个头用于告诉浏览器,服务器的类型
Content-Encoding: 这个头用于告诉浏览器,数据的压缩格式
Content-Length: 这个头用于告诉浏览器,数据的长度
Content-Type:这个头用于告诉浏览器,回送数据的类型
Last-Modified: 这个头用于告诉浏览器,资源的最后修改时间(缓存相关的头)
Refresh:这个头用于控制浏览器定时刷新,
Content-Disposition: 用于控制浏览器以下载方式打开回送的数据
Transfer-Encoding: 用于告诉浏览器,数据的传送方式
Expires: -1
Cache-Control: no-cache
Pragma: no-cache
以上三个都可以实现浏览器不要缓存资源数据
HTTP请求中的常用响应头
Location: http://www.baidu.org/index.jsp
Server:apache tomcat
Content-Encoding: gzip
Content-Length: 80
Content-Language: zh-cn
Content-Type: text/html; charset=GB2312
Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT
Refresh: 1;url=http://www.baidu.org
Content-Disposition: attachment; filename=aaa.zip
Transfer-Encoding: chunked
Set-Cookie:SS=Q0=5Lb_nQ; path=/search
ETag: W/"7777-1242234904000"
Expires: -1
Cache-Control: no-cache
Pragma: no-cache
Connection: close/Keep-Alive
Date: Tue, 11 Jul 2000 18:23:51 GMT
---------------------------------------------------------------------------------
Web端口:80开发是8080
Smtp:25
Pop3:110
ftp:23
https:443
打jar包
优惠原则:尽量减少http请求数。
Accept: 支持
响应头
客户端:
302 你向我借钱,我没钱,要你去找谁。
304,307:要你去拿缓存,拿缓存的数据显示
403,米有权限拒绝。
404:你请求的资源web服务器没有。
服务器:
500:服务器出错。
对实时性很高的软件,不能有缓存
ETag:实时缓存。
----------------------------------------------------------------------------------
在Servlet测试的几段http请求响应代码:
2..对http请求和响应的解析----
3..运用Range字段的 断点续传