详细,但复制自http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html上的HTTP 1.1方法规范
9.3获得
GET方法意味着检索由Request-URI标识的任何信息(以实体的形式)。如果Request-URI指的是一个产生数据的流程,则应将产生的数据作为响应中的实体返回,而不是流程的源文本,除非该文本恰好是流程的输出。
The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring multiple requests or transferring data already held by the client.
如果请求消息包含一个Range报头字段,GET方法的语义将更改为“部分GET”。部分GET请求只传输实体的一部分,如第14.35节所述。partial GET方法旨在通过允许完成部分检索的实体而不传输已经由客户端持有的数据来减少不必要的网络使用。
当且仅当GET请求的响应满足第13节中描述的HTTP缓存要求时,该响应是可缓存的。
关于表单使用时的安全注意事项,请参见15.1.3节。
9.5发布
POST方法用于请求源服务器接受请求中包含的实体,作为request - line中由request - uri标识的资源的新附属。POST被设计为允许一个统一的方法覆盖以下函数:
- Annotation of existing resources;
- Posting a message to a bulletin board, newsgroup, mailing list,
or similar group of articles;
- Providing a block of data, such as the result of submitting a
form, to a data-handling process;
- Extending a database through an append operation.
POST方法执行的实际功能由服务器决定,通常依赖于Request-URI。发布的实体隶属于该URI,就像文件隶属于包含它的目录,新闻文章隶属于发布它的新闻组,或者记录隶属于数据库一样。
POST方法执行的操作可能不会产生可以由URI标识的资源。在本例中,200 (OK)或204 (No Content)是适当的响应状态,这取决于响应是否包含描述结果的实体。
如果源服务器上已经创建了资源,响应应该是201(已创建),并包含一个描述请求状态的实体和指向新资源的实体,以及一个Location头(参见14.30节)。
此方法的响应是不可缓存的,除非响应包含适当的Cache-Control或Expires报头字段。然而,303 (See Other)响应可用于指示用户代理检索可缓存资源。
POST请求必须遵守8.2节中规定的消息传输要求。
安全注意事项请参见15.1.3节。
9.6把
The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request. If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.
如果请求经过缓存,而request - uri标识了一个或多个当前缓存的实体,那么这些条目应该被视为过期的。此方法的响应不可缓存。
The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI,
它必须发送一个301(永久移动)响应;用户代理可以自行决定是否重定向请求。
单个资源可以由许多不同的uri标识。例如,一篇文章可能有一个用于标识“当前版本”的URI,它与标识每个特定版本的URI是分开的。在这种情况下,一个通用URI上的PUT请求可能会导致原始服务器定义多个其他URI。
HTTP/1.1没有定义PUT方法如何影响源服务器的状态。
PUT请求必须遵守8.2节中规定的消息传输要求。
除非对特定的实体-头另有指定,否则PUT请求中的实体-头应该应用于PUT创建或修改的资源。
9.7删除
The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location.
如果响应包含描述状态的实体,那么成功的响应应该是200 (OK),如果操作尚未实施,则应该是202(已接受),如果操作已经实施,但响应不包括实体,则应该是204 (No Content)。
如果请求经过缓存,而request - uri标识了一个或多个当前缓存的实体,那么这些条目应该被视为过期的。此方法的响应不可缓存。