restful请求方式(下面哪几种属于ElasticSearch的RESTful请求方式())

本文目录
下面哪几种属于ElasticSearch的RESTful请求方式()
下面哪几种属于ElasticSearch的RESTful请求方式()
A.Post(正确答案)
B.Get(正确答案)
C.Delete(正确答案)
D.Update
怎么通过url向一个restful服务发出delete请求
DELETE方法是用来删除URL所指定的资源的,作为HTTP协议规定的方法之一,当然可以被使用,只是需要注意下面的一些细节,避免系统设计意外。
1、具体实现上,服务器可能会有自己变通的处理方式,比如出于安全、数据完整性的考虑,把`删除`转义为`禁用`,毕竟删除数据是危险的,需要意识到这一点
2、提交DELETE请求时,不能包含Entity Body。排除传输编码的要求,Entity Body实际上就是HTTP消息体:
The message-body (if any) of an HTTP message is used to carry the entity-body associated with the request or response.
The message-body differs from the entity-body only when a transfer-coding has been applied,
message-body = entity-body
| 《entity-body encoded as per Transfer-Encoding》
***隐藏网址***
A payload within a DELETE request message has no defined semantics;
sending a payload body on a DELETE request might cause some existing
implementations to reject the request.
***隐藏网址***
3、PUT/DELETE方法从语义上来讲,对资源是有破坏性的,PUT更改现有的资源,而DELETE摧毁一个资源,带有破坏性质的方法有时候会被防火墙或者IT管理人员特别关注,所以当提供PUT/DELETE接口服务时,需要确保服务器前置的防火墙没有block这些方法。当然如果走的是HTTPS协议,无需担心这一点。
java中使HttpDelete可以发送body信息
***隐藏网址***
public class MyHttpDelete extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
public String getMethod() {
return METHOD_NAME;
}
public MyHttpDelete(final String uri) {
super();
setURI(URI.create(uri));
}
public MyHttpDelete(final URI uri) {
super();
setURI(uri);
}
public MyHttpDelete() {
super();
}
}
使用delete方法时,直接可以按下面方式操作
***隐藏网址***
***隐藏网址***
List《NameValuePair》 nameValuePairs = new ArrayList《NameValuePair》();
delete.setEntity(new UrlEncodedFormEntity(nameValuePairs));
***隐藏网址***

更多文章:
给虚拟机提供操心系统的是哪个组件(以下哪些是云服务器ecs产品组件)
2026年11月7日 23:30
网页注册界面(怎样在网页中制作注册和登录界面谢谢了,大神帮忙啊)
2026年11月7日 22:50
apache是干嘛的(apache http server 和 tomcat是什么关系)
2026年11月7日 22:00
正则表达式015怎么写(// 最大,最小值1-15如何用正则写出来)
2026年11月7日 16:40
marginhtml(html用了浮动就不能使用margin了吗)
2026年11月7日 15:50
linux环境变量查看(怎么查看修改linux用户当前的环境变量)
2026年11月7日 11:10



