注:本文为个人学习摘录,原文地址为:http://javaeedevelop.iteye.com/blog/1725299

An HTTP request is a class consisting of HTTP style requests, request lines, request methods, request URL, header fields, and body content. The most common methods that are used by a client in an HTTP request are as follows:-

1) GET:- Used when the client is requesting a resource on the Web server.

    当客户端向Web服务器请求一个资源的时候使用。

2) HEAD:- Used when the client is requesting some information about a resource but not requesting the resource itself.

    当客户端向Web服务器请求一个资源的一些信息而不是资源的全部信息的时候使用。

3) POST:- Used when the client is sending information or data to the server—for example, filling out an online form (i.e. Sends a large amount of complex data to the Web Server).

    当客户端向服务端发送信息或者数据的时候使用--例如,表单提交(向Web服务器发送大量的复杂的数据)。

4) PUT:- Used when the client is sending a replacement document or uploading a new document to the Web server under the request URL.

    当客户端向Web服务端指定URL发送一个替换的文档或者上传一个新万当的时候使用。

5) DELETE:- Used when the client is trying to delete a document from the Web server, identified by the request URL.

    当客户端尝试从Web服务端删除一个由请求URL唯一标识的文档的时候使用。

6) TRACE:- Used when the client is asking the available proxies or intermediate servers changing the request to announce themselves.

    当客户端要求可用的代理服务器或者中间服务更改请求来宣布自己的时候使用。

7) OPTIONS:- Used when the client wants to determine other available methods to retrieve or process a document on the Web server.

    当客户端想要决定其他可用的方法来检索或者处理Web服务端的一个文档时使用。

8) CONNECT:- Used when the client wants to establish a transparent connection to a remote host, usually to facilitate SSL-encrypted communication (HTTPS) through an HTTP proxy.

    当客户端想要确定一个明确的连接到远程主机的时候使用,通常便于通过Http代理服务器进行SSL加密通信(Https)连接使用。

特定的HTTP服务器还能够扩展自定义的方法

9) PATCH:-用于将局部修改应用到资源。

1、The GET Request Method --Get请求方法

The GET method is the simplest and the most frequently used request method. It is used to access the static resources, such as HTML documents and images. GET request can be used to retrieve dynamic information by including query parameters in the request URL. For instance, we can send a parameter name with the URL, such as http://www.domain.com?name=Harsh. In this example, Harsh is the dynamic information sent by including a parameter,name, in the request URL. The Web Server can then access this dynamic information through the “name” parameter.

Get方法是最简单最常用的请求方法。它被用来访问静态资源,比如HTML文档和图片等。Get请求可以通过在请求URL中包含查询参数的方法来检索动态信息。例如,我们可以通过URL发送“name”这个参数(http://www.domain.com?name=Harsh),在这个例子中,Harsh是通过在请求URL中包含参数“name”的动态的信息。Web服务可以通过这个“name”参数来访问动态信息。

2、The HEAD Request Method -- Head方法

According to Wikipedia “Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.” It is used when the client is requesting some information about a resource but not requesting the resource itself. This means that we have a faster way of checking the headers and some server info for a given resource on the server i.e. checking if a given url is serviceable, a given file exists, etc..Sometimes client might only need to view the header of a response (Content-Type or Content-Length). The client can use the HEAD request method to retrieve the header in such cases. The HEAD method is similar to GET method, except that the server does not return a message body (actual page) in response of the HEAD method.

根据维基百科“要求响应上等同于Get请求,但是没有响应Body(Response Body)。这在检索写在响应头(Response Header)中的信息而不需要传输全部的内容的情况下非常有用。”当客户端请求关于一个资源的一些信息而不是请求全部资源的时候使用Head方法。这意味着我们有一种快速的方式来检查针对服务端上一个给定的资源的头信息和一些服务端信息,检测一个给定的url是否可用、给定的文件是否存在等等。有时客户端仅仅需要查看相应的头信息(Content-Type或者Content-Length)。在此类案例中客户端可以使用HEAD请求方法来检测头信息。HEAD方法与GET方法类似,但是HEAD方法不希望在响应信息中包含Message Body(实际页面)。

3、The POST Request Method--Post方法

The Post method is commonly used for accessing dynamic resources or when a large amount of complex information is to be sent to the server. The Web Server accepts the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI( Uniform Resource Identifier). According to Wikipedia “Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.” The major difference between GET and POST is that in GET the request parameters are transmitted as a query string appended to the request URL, while in POST the request parameters are transmitted within the body of the request.

Post方法一般用来访问动态资源,或者在向服务端发送大量的复杂信息的时候使用。Web服务器接收封装在Request中的实体,作为请求URI唯一标识的资源的附属。根据维基百科“提交数据被处理到唯一标识资源。数据被包含在请求的Body(Request Body)中。这可能会导致创建一个新的资源或者更新已有的资源或者两者兼之。”Get方法和Post方法的主要区别是:在Get方法请求中,请求参数是附加在请求URL最后来传输的,而在Post方法中,请求参数是被包含在请求体(Request Body)中传输的。

The POST request method provides the following functionalities:
1) Providing annotations of the existing resources.
2) Posting a message to a bulletin board, newsgroup, mailing list, or a similar group of articles.
3) Providing a block of data, such as the result of the submitting a form, to a data-handling process.
4) Extending a database through an append operation.

Post请求方法提供了如下功能:

(1)为存在的资源提供注释。

(2)发布信息给公告牌、新闻组、邮件列表或者一组类似的文章。

(3)提供一块数据,例如提交Form表单到数据处理单元的结果。

(4)通过附加操作扩展数据库。

4、The PUT Request method--Put方法

The PUT method stores an entity in the specified Request-URI. The entity is a resource residing on the Web server under the specified Request-URI. If the Request-URI does not point to an existing resource, but is capable of being defined as a new resource by the requesting user, the Web Server can create the resource with that URI. If an existing resource is modified, either the 200(OK) or 204 (No Content) response code should be sent to indicate successful modification of a resource. The Web Server must inform the user via the 201 (Created) responses if a new resource is created. If the resource is not created or modified with the Request-URI, an appropriate error response is generated, which reflects the nature of the problem.

Put方法存储一个实体到指定的请求URI。该实体是Web服务端上指定请求URI下的资源。如果请求URI没有指向一个存在的资源,也能被发出请求的用户定义为一个新的资源,Web服务端将使用该URI创建资源。如果一个已经存在的资源被修改,200(OK)或者204(No Content)响应代码将被发送来表示成功修改资源。如果一个新的资源被创建,Web服务端必须向用户返回201(Created)相应代码。如果指定请求URI没有创建或者修改资源,将产生一个适当的错误响应,以反应问题的性质。

5、The DELETE Request method--Delete方法

The DELETE method requests the Web server to delete the resource identified by the Request-URI. This method may be overridden by human intervention (or other means) on the Web Server. If the response includes an entity describing the status of deletion, the 200(OK) response code specifies that the resource has been deleted successfully. If the response is 202(Accepted), it specifies that the resource has not yet been deleted. Similarly, if the response code is 204 ( No Content), it specifies that the resource has been deleted but the response code does not include an entity.

Delete方法通过请求URI请求Web服务删除指定资源。该方法可能在Web服务端被人为的重写。如果响应信息中包含一个实体描述删除的状态,200(OK)相应代码指出资源已经被成功删除。如果响应代码是202(Accepted),它指出资源还没有被删除。相似的,如果相应代码是204(No Content),它指出资源已经被删除但是响应代码不包含任何实体。

6、The OPTIONS Request method--Options方法

According to Wikipedia “Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource.”
The OPTION method requests for information about the communication options available on the request/response chain identified by a Request-URI. Responses to this method are not cacheable. This method allows the client to determine the options and /or requirements associated with a resource, or the capabilities of a server. If the OPTIONS method includes an entity body, the media type must be indicated by the content-type field.

根据维基百科“返回服务端针对指定的URL所支持的HTTP请求方法。用“*”代替资源名称,想Web服务器发送Options请求,可以测试服务器功能是否正常运作。"Options方法请求关于可请求URI所表示的请求/响应链上的用的通信选项的信息。该方法的响应信息不能被缓存。该方法允许客户端决定选项和/或要求与一种资源或者服务的功能相关联。如果Options方法包含一个实体,则media类型必须通过Content-Type字段来标明。


7、The TRACE Request method--Trace方法

According to Wikipedia “Echoes back the received request, so that a client can see what (if any) changes or additions have been made by intermediate servers.”
The TRACE method is used to invoke a remote application layer associated with a request message. A TRACE request must not include an entity. A client uses the TRACE method to see the received input at the other end of the request chain and diagnostic or testing information.

根据维基百科“回显服务器收到的请求,这样客户端可以看到(如果有)哪一些改变或者添加已经被中间服务器实现。”Trace方法被用来调用与请求消息相关联的远程应用程序层。Trace请求必须包含一个实体。客户端使用Trace方法看到接收用户输入的请求链和诊断或检测信息的另一端。

HTTP Request GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE Methods的更多相关文章

  1. 杂项-协议-HTTP:GET/POST/PUT/DELETE/INPUT/TRACE/OPTIONS/HEAD方法

    ylbtech-杂项-协议-HTTP:GET/POST/PUT/DELETE/INPUT/TRACE/OPTIONS/HEAD方法 1.返回顶部 1. 请求方法是请求一定的Web页面的程序或用于特定的 ...

  2. cURL(wget)—— 测试 RESTful 接口及模拟 GET/POST/PUT/DELETE/OPTIONS 请求

    cURL 是一个简单的 http 命令行工具.与最优秀的 Unix 工具一样,在设计之时,cURL 是个小型程序,功能十分专一,而且是故意为之,仅用于访问 http 服务器.(在 Linux 中,可以 ...

  3. nginx实现跨域访问并支持(GET, POST,PUT,DELETE, OPTIONS)

    最近有同事提出在使用客户端跨域访问的时候,发现服务器对option请求返回了403,后来查看了网络添加了一段配置,发现option服务返回204了,但是后续的put操作也直接返回了204导致无法使用图 ...

  4. request有get,post,put,delete等方法大全

    注:本文为个人学习摘录,原文地址为:http://javaeedevelop.iteye.com/blog/1725299 An HTTP request is a class consisting ...

  5. get? post? put? delete? head? trace? options? http请求方法

    http1.1协议里面定义了八种请求方法: get:用作获取,读取数据 post:向指定的资源提交数据 put:更新,向指定的资源上传一个内容,比如说:更新一个用户的头像或者替换掉已有的一个视频 de ...

  6. GET,POST,PUT,DELETE,OPTIONS等请求方式简单总结

    之前做的java web项目,基本上只使用get和post的请求方式,但是现在新项目额外增加了put,delete,查了点资料,做个简单的总结. 1.GET-安全且幂等 get请求是用来获取数据的,只 ...

  7. Python 基于request库的get,post,delete,封装

    # coding=utf-8 import json import requests class TestApi(object): """ /* @param: @ses ...

  8. HTTP1.1新增了五种请求方法:OPTIONS、PUT、PATCH、DELETE、TRACE 、 CONNECT

    200 (成功) 服务器已成功处理了请求. 通常,这表示服务器提供了请求的网页. 201 (已创建) 请求成功并且服务器创建了新的资源. 202 (已接受) 服务器已接受请求,但尚未处理. 203 ( ...

  9. org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PUT' not supported

    1:先上控制台报错信息 org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PUT' not ...

随机推荐

  1. ng动态显示和隐藏

    <!DOCTYPE html><html><head><meta charset="utf-8"><script src=&q ...

  2. lua中string常用api

    local a="abcdefgbbb" string.sub(a,1,3) 字符串截取 返回截取的字符串           print(string.sub(a,1,3))   ...

  3. 转载:c# string.Format

    C#:STRING.FORMAT数字格式化输出 1.各种常用数字格式化 货币转换 C 或 c(默认小数点后2位.C3后面跟的数字就代表小数后几位)    string.Format("{0: ...

  4. hdu1036

    #include<stdio.h>int main(){ int n; double d; int num; char h,m1,m2,s1,s2; scanf("%d" ...

  5. glusterfs快速安装

    因为公司ES02集群使用的是SSD磁盘做的raid0,为了保证存放文件的可靠性,即在ES02集群上部署了一套分布式文件系统glusterfs.   结构 ES11    含有gfs程序,并挂载gfs在 ...

  6. 【NOIP2006提高组】能量项链

    说好的好好写人话的题解 嗯很多题解都说过这是一个石子合并的模型它也确实就是一个石子合并的模型.然而就算这样我也不会写最后仍然写了个记忆化搜索 首先我们不论环状,就直接一条链型,当只剩下两个珠子的时候, ...

  7. C#在客户端验证数字证书(Certificate)

    ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallback;//Init时执行,用于 ...

  8. SQL中游标的使用--遍历数据逐行更新或删除:相当于for循环

    --------------------------------------例子1 单纯的游标-------------------------------- create TABLE Table1 ...

  9. rpm 安装包制作

    rpm 安装包制作 思路 参照系统自带 etcd 解压->替换掉执行文件->打包 1 预备安装工具 下载工具 yumloader #yum install -y yum-utils 解压工 ...

  10. Python基础(十)-模块

    模块初识 一般把不同功能代码放到不同py文件,一个py文件就是一个模块 三种模块库: 1.Python标准库 2.第三方库 3.自定义库 导入模块:import 库名 (Python解释器只认识执行文 ...