What are the HTTP Request Methods (Get, Post, Put, )?

About

The http method 1) is a mandatory header of http request that defines the type of operation.

Example

A minimal get request from this page

GET https://datacadamia.com/web/http/method HTTP/1.1
Host: datacadamia.com

Usage

Example of definition of:

openapi: 3.0.0
paths:
  /pet/findByStatus:
    get:
      tags:
        - pet
      summary: Finds Pets by status
      description: Multiple status values can be provided with comma separated strings
      operationId: findPetsByStatus
      parameters:
        - name: status
          in: query
          description: Status values that need to be considered for filter
          required: true
          style: form
          explode: false
          deprecated: true
          schema:
            type: array
            items:
              type: string
              enum:
                - available
                - pending
                - sold
              default: available
      responses:
        '200':
          description: successful operation
          content:
            application/xml:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'

List

HTTP defines a set of operations. By order of most frequent:

Method UnSafe
Change state ?
Description Cached by default Html element Request Body Used May be cached
GET No (Default) Transfer a current representation of the target resource.
Commonly used to download web pages
A GET request retrieve data.
GET requests will never cause an update or change to your data because they’re safe and idempotent.
Yes Html, Img, Link No Yes
POST Yes Perform resource-specific processing on the request payload.
Commonly used to transmit form submission data to a web server.
A POST request creates generally new resources..
No Form Yes No
PATCH Yes Update a resource
With PATCH requests, you only need to provide the data you want to change
No
PUT Yes Replace all current representations of the target resource with the request payload.
Create or update a resource
May be used for Data syncing
No No
HEAD No Same as GET, but only transfer the status line and header section. No No
DELETE Yes Remove all current representations of the target resource No No
CONNECT No Establish a tunnel to the server identified by the target resource. No No
OPTIONS No Describe the cross communication options for the target resource. No No
TRACE No Perform a message loop-back test along the path to the target resource. No No

Other protocols based on HTTP can define additional methods.

All general-purpose servers MUST support the methods GET and HEAD. All other methods are OPTIONAL.

A request method is considered idempotent

Syntax

The syntax is defined in the section 3.1.1. Request Line

In a http message

method         = token

where token defines the method

Management

Allowed

The set of methods allowed by a target resource can be listed in an Allow header field (Section 7.4.1).

However, the set of allowed methods can change dynamically.

When a request method is received that is:

  • unrecognized or not implemented by an origin server, the origin server SHOULD respond with the 501 (Not Implemented) status code.
  • known by an origin server but not allowed for the target resource, the origin server SHOULD respond with the 405 (Method Not Allowed) status code.

Safe/Unsafe

Safe request have methods that does not changes state while unsafe request does.





Discover More
(HTTP|HTTPS) - Hypertext Transfer Protocol

Hypertext Transfer Protocol (HTTP) is the transfer protocol to exchange or transfer web resource between nodes (host). The H in HTTP means an hypertext (ie HTML). The protocol was first designed...
Aws Serverless Web App
AWS - Serverless Web Application

Note the AWS tuto Amazon tuto - Build a Serverless Web Application that create a serverless...
Cors Flowchart
Browser - Cross Origin Resource Sharing (CORS)

Cross-origin resource sharing (CORS) is a mechanism that: * allows a HTTP server * to control the cross-origin requests executed by a browser. In short, a HTTP server may allow or not to receive...
Card Puncher Data Processing
Consumer Analytics - Event Collector

A collector collects event send by a tracker The event and data send are describe in a measurement protocol Data aggregation refers to techniques for gathering individual data records (for example...
HTML Form - 1001 ways to submit a Form and handle the corresponding Event

This page talks and shows all the ways on how to submit a form and handle the submit event in javascript. How a form can be submitted ? HTML One way is to include a input element of type submit that...
Http Cache Partitioning Example
HTTP - Cache Store

A cache store is an http cache component that caches the http response if the cache control header permits it. There is two type of cache: intermediate cache (proxy) client cache (user-agent cache...
HTTP - DELETE

delete is a http request method that should perform a data delete operation
HTTP - Get Method

The HTTP GET method is the default request retrieval action of the HTTP protocol. For example, the same than RETR in FTP. GET is the primary mechanism of information retrieval. A payload within a GET...
HTTP - HEAD method

The HTTP HEAD method requests the headers that are returned if the specified resource would be requested with an HTTP GET method. ...
Chrome Options Request
HTTP - OPTIONS Request Method

OPTIONS is a request method used in CORS procedure (ie the the “pre-flight” request) asking the server for the CORS headers, but without data. Trying to fetch data from ...



Share this page:
Follow us:
Task Runner