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));
***隐藏网址***

更多文章:
python中value函数(python如何无限遍历字典中的value,在不知道字典里面有几层字典的时候)
2026年9月23日 07:10
lenovo是什么梗(为什么有人说联想是美国的求解,这是个什么梗)
2026年9月23日 06:30
FPS是什么 FPS游戏的定义和特点?好玩的FPS单机游戏有哪些
2026年9月23日 04:40
flex嵌套flex(flex怎么嵌入外部网页,比如在flex的容器中(如panel)显示出新浪、百度首页 最好能有直接运行的例子)
2026年9月23日 03:30






