常见的头信息
请求头:
Accept: text/html,image/* --告诉服务器当前客户端可以接收的文档的类型。其实这里包含了*/*,就表示什么都可以接收; 大类型/小类型 比如 text/css text/javascript.
Accept-Charset: ISO-8859-1 --告诉服务器,客户端提交的表单可能使用的编码类型
Accept-Encoding: gzip --浏览器发给服务器,声明浏览器支持的编码类型
Accept-Language:zh-cn --语言环境.
Host: localhost:8080 --访问主机
If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT 客户端第二次请求此URL时,根据 HTTP 协议的规定,浏览器会向服务器传送 If-Modified-Since 报头,询问该时间之后文件是否有被修改过:
后面跟的时间是本地浏览器存储的文件修改时间
Referer: http://www.baidu.com/index.jsp --来自哪个页面、防盗链
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Cookie
Connection:Keep-Alive --链接状态 长链接
Date: Tue, 11 Jul 2000 18:23:51 GMT --时间
响应头
响应头
Location: http://www.baidu.org/index.jsp --跳转方向 302重定向
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 在浏览器第一次请求某一个URL时,服务器端的返回状态会是200,内容是你请求的资源,同时有一个Last-Modified的属性标记此文件在服务期端最后被修改的时间,
Refresh: 3;url=http://www.hehe.org --延时3s跳转页面
Content-Disposition: attachment; filename=aaa.zip --下载
Set-Cookie:SS=Q0=5Lb_nQ; path=/search
Expires: -1 --缓存 就是让页面立即过期
Cache-Control: no-cache --浏览器和缓存服务器都不应该缓存页面信息强制每次请求直接发送给源服务器,而不经过本地缓存版本的校验
Connection: Keep-Alive --保持连接 长链接
Date: Tue, 11 Jul 2000 18:23:51 GMT
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
response.getWriter().write("进入了demo11,接下来3秒钟后进入demo10");
response.setHeader("refresh", "3;url=/ResponseDemo/ResponseDemo10"); //设置刷新头延时3秒跳转页面
}