request method

来源:互联网 发布:知乎和百度有什么区别 编辑:程序博客网 时间:2024/06/05 18:45

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:-

HTTP请求是一个类组成的HTTP请求,请求,请求方法,请求URL,头字段和正文内容。最常见的方法是使用一个客户在一个HTTP请求如下:-
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.
客户端请求时使用的一些信息资源而不是请求资源本身。
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 serve
使用客户端想要确定其他可用的方法来检索或流程文档在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.
使用客户端希望建立一个透明连接远程主机,通常为了方便ssl加密通信通过一个HTTP代理(HTTPS)。
The GET Request Method

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,如http://www.domain.com?name=Harsh。在这个例子中,残酷的是发送的动态信息,包括一个参数名称,在请求URL。Web服务器可以访问这个动态信息通过“名字”参数。
The HEAD Request Method

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请求,但是没有身体的反应。这是用于检索元信息写在响应头,无需传输整个内容。“这是客户端请求时使用的一些信息资源而不是请求资源本身。这意味着我们有一个更快的方式检查标题和一些服务器信息对于一个给定的资源在服务器上即检查给定的url是有用的,一个给定的文件存在,等。有时客户可能只需要查看响应的头(内容类型或内容长度)。客户端可以使用HEAD请求方法检索标题在这种情况下。头的方法类似于GET方法,除了服务器不返回一个响应消息体(实际页面)的方法。

The POST Request Method

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.
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方法通常用于访问动态资源或者当大量复杂的信息发送到服务器。Web服务器接受实体包含在请求作为一种新的资源得到由请求uri所指定资源的下属(统一资源标识符)。根据维基百科“提交数据处理(如。,从一个HTML表单)到指定的资源。数据被包含在请求的主体。这可能导致创建一个新的资源或更新现有的资源或两者兼而有之。“GET和POST之间的主要区别是,在获得请求参数传输作为一个查询字符串附加到请求URL,而在POST请求参数是身体内的传输请求。

POST请求的方法提供了以下功能:-

1)提供注释的现有资源。

2)发布消息给公告板,新闻组、邮件列表,或者一群相似的文章。

3)提供的数据块,如提交表单的结果,数据处理流程。

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


The PUT Request method

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方法将一个实体存储在指定的要求通用。实体是一个资源驻留在Web服务器在指定要求通用。如果要求通用不指向现有资源,但可以被定义为一个新的资源请求用户,Web服务器可以创建资源的URI。如果修改现有资源,要么是200(OK)或204(无内容)发送响应代码来表示资源的成功修改。Web服务器必须通知用户通过201(创建)反应如果创建一个新资源。如果资源不创建或修改要求通用,生成一个适当的错误响应,这反映了问题的性质。

The DELETE Request method

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方法请求Web服务器删除资源得到由请求uri所指定资源。这个方法可能会被人工干预在Web服务器(或其他方式)。如果响应包含一个实体描述的状态删除,200(OK)响应代码指定的资源已被删除成功。如果响应是202(接受),它指定资源尚未被删除。类似地,如果响应码是204(无内容),它指定的资源已被删除,但响应代码不包括一个实体。

The OPTIONS Request method

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.

根据维基百科”返回HTTP方法的服务器支持指定的URL。这可以用来检查web服务器的功能通过请求‘*’而不是一个特定的资源。”

选择方法的请求信息通信选项可以在请求/响应链被要求通用。此方法反应不缓存。这种方法允许客户端决定与资源相关的选项和/或需求,或者服务器的功能。如果选择方法包括一个实体机构,媒体类型必须由content - type字段表示。



The TRACE Request method

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.

根据维基百科“回声返回接收到的请求,这样客户可以看到(如果有的话)更改或添加已经由中间服务器。”

跟踪方法用于调用一个远程应用程序层请求消息。跟踪请求必须不包括一个实体。客户使用跟踪方法看到接收到的输入请求链的另一端和诊断或测试信息。


0 0
原创粉丝点击