Updated on 2023-07-14 GMT+08:00

Constructing a Request

A request consists of three parts: a request line, request header, and request body (optional).

Request Line

A request line starts with the request method, which is followed by the uniform resource identifier (URI) and protocol version. The request method and URI are separated by a space. The request line format is as follows:

Method Request-URI HTTP-Version CRLF
  • Method: request method. All methods are capitalized and their meanings are as follows:
    • GET: obtains the resource identified by the Request-URI.
    • POST: suffixes new data to the resource identified by the Request-URI.
    • PUT: stores a resource identified by the Request-URI.
    • DELETE: deletes the resource identified by Request-URI.
  • Request-URI: uniform resource identifier.

A combination of different query conditions can be added at the end of the URI by using question marks (?) and ampersands (&). The content contained in {} in the URI is the parameters of the URI, where ? is contained. The part preceding ? is the path parameter, and the part following ? is the query parameter. HTTP-Version: version of the HTTP protocol used by a request.

  • CRLF: carriage return and line feed characters. CRLF is placed only at the end of a line. CR and LF must be present at the same time.

Request Header

A request header consists of several fields, each including a domain name, colon (:), and field value. For details, see Common Request Header Fields.

Request Body

A request body is a JSON-based, nested key:value pair. The mandatory and optional fields of an HTTP request body vary depending on the URI.