HTTP1.1 head,get, post, put, patch, delete, options , trace, connect 八大方法的区别和使用方法
head : 获取资源(类似select) , 但响应不能返回实体
get : 获取资源(类似select) , 安全, 幂等
post: 代表可能改变服务器资源的请求(insert)
put : (update) 对整个资源进行更新
patch : (局部update) 对局部明确的资源进行更新, 只提交需要修改的部分内容
delete : (delete) 删除资源
options : 查询目标资源的请求方法等信息
trace : 调试用, 按照资源路径测试回环
connect : 做代理, 向代理服务器做请求建立一条隧道
针对 options , trace ,我在服务器创建了一个index.html文件, 测试结果如下
# OPTIONS , 得到允许的请求方法有POST,OPTIONS,GET,HEAD,TRACE, 服务允许在apache下,php版本为7.2.31
[root@VM_0_17_centos html]# telnet xiao5.fun 80
Trying 119.28.203.193...
Connected to xiao5.fun.
Escape character is '^]'.
OPTIONS /index.html HTTP/1.1
Host: xiao5.fun
HTTP/1.1 200 OK
Date: Sat, 30 May 2020 15:32:57 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.2.31
Allow: POST,OPTIONS,GET,HEAD,TRACE
Content-Length: 0
Content-Type: text/html; charset=UTF-8
# TRACE 得到Transfer-Encoding, Content-Type , 说明资源可达
[root@VM_0_17_centos html]# telnet xiao5.fun 80
Trying 119.28.203.193...
Connected to xiao5.fun.
Escape character is '^]'.
TRACE /index.html HTTP/1.1
Host: xiao5.fun
HTTP/1.1 200 OK
Date: Sat, 30 May 2020 15:37:23 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.2.31
Transfer-Encoding: chunked
Content-Type: message/http
2f
TRACE /index.html HTTP/1.1
Host: xiao5.fun
简单表述REST风格的理解
主要描述如何设计网络接口 : 用URL定位资源,用HTTP动词描述操作 , 用返回status_code 得知结果
网友评论