`
javaEEdevelop
  • 浏览: 876274 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

HTTP Request GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE Methods

 
阅读更多

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.

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).

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

5) DELETE:- Used when the client is trying to delete a document from the Web server, identified by the request 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. 

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.

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.

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.

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.

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.

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.

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.

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.

分享到:
评论

相关推荐

    UniApp中封装request网络请求包含GET、POST、PUT、DELETE等

    本教程将详细介绍如何在UniApp中封装request网络请求,包括GET、POST、PUT和DELETE四种常见的HTTP方法。 首先,我们需要了解HTTP协议中的这四种方法: 1. GET:获取资源,是最常用的方法,用于从服务器上获取特定的...

    关于get.post delete put 的用法

    在 HTTP 中,定义了多种方法来与服务器进行交互,今天我们来详细讲解 GET、POST、DELETE、PUT 等方法的用法。 OPTIONS 方法 OPTIONS 方法用于返回服务器针对特定资源所支持的 HTTP 请求方法。这个方法可以让客户端...

    对Django 中request.get和request.post的区别详解

    Django 中request.get和request.post的区别 POST和GET差异: POST和GET是HTTP协议定义的与服务器交互的方法。GET一般用于获取/查询资源信息,而POST一般用于更新资源信息。另外,还有PUT和DELETE方法。 POST和GET都...

    restlight:使用Android和Java编写的HTTP库中的Restlight,在HTTP como中的用法:GET,POST,HEAD,OPTIONS,PUT,DELETE和TRACE; 外部hacia servidores

    休息灯Restlight ES UNA LIBRERIA HTTP对Android的Ÿ的Java,阙facilita拉creación德peticiones科莫HTTP:GET,POST,HEAD,OPTIONS,PUT,DELETEÿTRACE; 外部hacia servidores。 o耶普洛斯要求提供奶油冰淇淋。 ...

    Android-HttpClient工具类简单轻松的实现getpostput和delete请求

    在Android开发过程中,网络请求是不可或缺的一部分,而`HttpClient`是一个强大的HTTP客户端库,它允许开发者执行各种HTTP操作,如GET、POST、PUT和DELETE。本篇文章将详细讲解如何使用`HttpClient`工具类来简化这些...

    get、post、request的区别

    在PHP编程中,了解HTTP请求方法,特别是GET、POST和REQUEST的作用至关重要,因为它们涉及到如何接收和处理客户端发送的数据。让我们深入探讨这三个变量的区别以及如何在实际应用中使用它们。 首先,`$_GET`变量用于...

    java web学习_浅谈request对象中get和post的差异

    Java Web 学习之 Request 对象中 GET 和 POST 的差异 摘要:本文将对 Java Web 中 Request 对象中 GET 和 POST 方法的差异进行分析和比较,通过代码示例和输出结果,展示 GET 和 POST 方法的不同之处,并分析其优...

    Http协议的Delete和Put方法用法

    一般来说,Web服务器默认的只支持Post和Get这两种“只读”的请求方法。但是随着Ajax XMLHttpRequest 和 REST风格应用的深入,我们发现Http 1.1协议还支持如下请求方法(Request Method): •OPTIONS •HEAD •...

    go-httprequest 简介 Go语言的HTTP请求包,功能特性: 线程安全 链式语法 支持GET,POST,PUT,P

    支持GET,POST,PUT,PATCH,HEAD,DELETE,OPTIONS,TRACE方法 可按间隔时间和最大次数自动重发请求 可定义多个URL轮循请求,当请求失败时自动使用下一个URL重发请求 对响应数据进行类型转换 导入路径 github....

    xhrhttprequest部分浏览器中不支持put/delete

    这些浏览器可能只支持GET和POST,而忽视了RESTful API设计中常用的PUT和DELETE。这在实现Web应用程序,尤其是那些遵循REST原则的应用程序时,会带来一定的困扰。 解决这个问题有几种策略: 1. 使用jQuery或其他库:...

    android http (get, post, put)封装

    这里的`sendGetRequest`、`sendPostRequest`和`sendPutRequest`方法分别封装了GET、POST和PUT请求。`RequestBody.create`用于创建请求体,`MediaType.parse`指定数据类型。 3. 在实际使用时,调用这些方法即可: ``...

    Python实现简单的HTTP服务器(GET/POST)

    本文将深入探讨如何使用Python实现一个简单的HTTP服务器,支持GET和POST请求。通过理解这个过程,你可以更好地理解网络通信的基本原理,以及Python在网络编程中的应用。 首先,让我们了解HTTP(超文本传输协议)的...

    httpclient 执行get/post/put代码

    本文将深入探讨如何使用HttpClient执行GET、POST和PUT操作,同时结合给定的`HttpsRequestUtil.java`源码片段进行解析。 HttpClient库允许我们构建灵活、高效的HTTP客户端,支持多种请求方法,包括GET、POST和PUT。...

    VC++ HTTP Get Post请求

    在VC++编程环境中,HTTP(超文本传输协议)Get和Post请求是常见的网络通信方法,主要用于从或向Web服务器发送数据。MFC(Microsoft Foundation Classes)库为VC++提供了便捷的方式来实现这些功能。本文将详细讲解...

    Go语言中的gin框架之GET/POST请求参数接收传值(五)

    本教程将详细讲解如何在Gin中接收GET和POST请求的参数。 首先,我们需要引入Gin库。在`go.mod`文件中,确保你有以下依赖: ```go module example.com/gin_get_post go 1.14 require ( github....

    Ajax中get和post区别

    "Ajax中Get和Post请求的区别" Ajax作为异步JavaScript和XML的简写,是一种创建交互式网页的技术。其中,Get和Post是两种常用的HTTP请求方法,尽管它们都是用于将数据从客户端发送到服务器端,但是它们之间存在着很...

    vue 对axios get pust put delete封装的实例代码

    在这篇文章中,我们将详细探讨如何在Vue项目中封装axios库来执行GET、POST、PUT和DELETE请求。文章中提供了具体的实例代码和解释,以帮助Vue开发者更好地理解和应用这些HTTP请求。首先,需要说明的是axios是一个基于...

    http发送Get和Post请求工具类

    在`HttpUtils`中,通常会包含两个主要方法:`sendGetRequest`和`sendPostRequest`,分别用于执行GET和POST请求。 1. **GET请求**: - GET请求常用于获取服务器上的资源,它是无状态的,参数通过URL传递。`...

    C++实现HTTP GET,POST请求

    本篇文章将详细探讨如何使用C++来实现HTTP GET和POST请求,以及涉及HTTPS的安全连接。 HTTP GET请求是HTTP协议中最基础的操作之一,主要用于从服务器获取资源。GET请求的所有参数都包含在URL中,因此它是透明且可...

Global site tag (gtag.js) - Google Analytics