HTTP相关
来源:互联网 发布:windows api函数 编辑:程序博客网 时间:2024/06/07 06:54
* HTTP协议的版本 * HTTP/1.0 * 链接后,只能获取一个web资源。 * 链接后,发送请求,服务器做出响应,链接立即断开。 GET /aa/1.html HTTP/1.0 host:localhost * HTTP/1.1(使用) * 链接后,可以获取多个web资源。 * 链接后,发送请求,服务器做出响应,链接不会立即断开。 再次发送请求,直接有一段时间没操作,自动断开。 GET /aa/1.html HTTP/1.1 host:localhost * 请求: * 请求行 * 请求方式 * POST、GET、HEAD、OPTIONS、DELETE、TRACE、PUT、CONNECT * 常用post和get * 区别: * get把参数显示在地址栏上,安全级别低,不支持大数据。 * post把参数封装请求体中,安全级别高,支持大数据。 * 请求地址 * 请求资源 * 协议版本 * HTTP/1.1 * 请求头 Accept: text/html,image/* Accept-Charset: ISO-8859-1 Accept-Encoding: gzip Accept-Language:zh-cn Host: www.itcast.com:80 If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT Referer: http://www.jindh.com/index.jsp User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) Connection: close/Keep-Alive Date: Tue, 11 Jul 2000 18:23:51 GMT * 重要的头 * If-Modified-Since 必须和响应头信息一起来完成控制本地的缓存。 * Referer 当前的网页的来源。(防止盗链)] * ``` public class RefererServlet extends HttpServlet {/** * 防止倒链 */public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String refer = request.getHeader("Referer"); if(refer.startsWith("http://localhost:8080/gofr/good")){ response.getWriter().write("<h1>欢迎</h1>"); }else{ response.getWriter().write("<h1>你妹的,盗我资源!</h1>"); } String agent = request.getHeader("User-Agent"); System.out.println(agent);}public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response);}
}
``` * User-Agent 判断浏览器的版本(文件下载的时候) * 空行 * 请求体 * 封装post参数列表。 * 响应 * 响应行 * 协议版本 * HTTP/1.1 * 状态码 200 :请求成功处理,一切OK 302 :请求重定向 304 :服务器端资源没有改动,通知客户端查找本地缓存 404 :客户端访问资源不存在 500 :服务器内部出错 * 状态码描述 * 响应头 Location: http://www.it315.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.it315.org Content-Disposition: attachment; filename=aaa.zip Expires: -1 Cache-Control: no-cache Pragma: no-cache Connection: close/Keep-Alive Date: Tue, 11 Jul 2000 18:23:51 GMT * 重要的头 * Location 和302一起完成重定向。 * Last-Modified 和请求头If-Modified-Since一起控制缓存。和状态码304 * Refresh 完成页面的定时跳转 * Content-Disposition 设置文件是以附件打开 Expires: -1 Cache-Control: no-cache Pragma: no-cache * 禁用缓存(网银系统) * 空行 * 响应体 * 存放真正的数据。
1 0
- HTTP相关
- HTTP相关
- HTTP相关
- http相关
- HTTP相关
- http相关
- http相关
- HTTP相关
- HTTP相关
- HTTP相关
- https相关、http相关
- HTTP 相关函数库
- http相关错误
- http相关的错误
- HTTP 协议相关
- HTTP 相应头相关
- php学习--http相关
- IOS http断点续传相关
- Ubuntu 16.04 安装最新版本wine
- 安卓面试小结.
- STM32 NUCLEO LoRa扩展板I-NUCLEO-LRWAN1简介
- code force. Anton and fairy tale.
- HTTP状态码对照表 HTTP response codes
- HTTP相关
- 新知识点:EventHandler学习
- 如何删除Github上面的项目
- 蓝桥杯-地址格式转换
- HTTP请求方法对照表
- 用JAVA awt实现Image Asset Studio生成圆形或圆角矩形图片功能
- Python函数
- 杭电2002计算球体积
- nginx 禁止访问.svn .git目录