请求头:
GET /myweb/index.html HTTP/1.1(请求行) 消息头 Accept-Encoding gzip, deflate Host localhost:8080 User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) Accept text/html, application/xhtml+xml, / Accept-Language zh-CN
响应头:
HTTP/1.1 304 Not Modified(状态行) 消息头 ETag W/“37-1368603309298” Content-Type text/html Content-Length 37 Last-Modified Wed, 15 May 2019 07:35:09 GMT *必须要有一个空行表示消息头结束 内容 abcdefg
让浏览器定时刷新:
刷新: response.setHeader(“Refresh”, “2”); response.getWriter().println(new java.util.Date()); 跳转: response.getWriter().write(“sdfsdfs”); response.setHeader(“refresh”, “3;url=/WebDemo/index.jsp”);
防止盗链referer:
response.setContentType(“text/html;charset=UTF-8”); String referrer = request.getHeader(“referer”); String server = “http://”+request.getServerName(); System.out.println(referrer); if(referrer!=null&&referrer.startsWith(server)){ System.out.println(“ok”); }
|