Home » HTTP Request

HTTP Request

HTTP Requests are messages which are sent by the client or user to initiate an action on the server.

The first line of the message includes the request message from the client to the server, the method which is applied to the resource, identifier of the resource, and the protocol version.

Syntax

Request Line

The Request-Line starts with a method token, which is followed by the Request-URI, the protocol version, and ending with CRLF. Using the SP characters, the elements are separated.

Syntax

1) Method

The method token is used to indicate the method which was performed on the resource identified by the Request-URI. The method is case sensitive.

Syntax

A resource is allowed a list of methods and that methods can be specified in an Allow header field. The response’s return code always notifies the client whether a method is currently allowed on a resource. Since the set of allowed methods can be changed dynamically.

Method and Description:

i) GET

This method retrieves information from the given server using a given URI. GET request can retrieve the data. It cannot apply other effects on the data.

ii) HEAD

The HEAD method is the same as the GET method. It is used to transfer the status line and header section only.

iii) POST

The POST request sends the data to the server. For example, file upload, customer information, etc. using the HTML forms.

iv) PUT

The PUT method is used to replace all the current representations of the target resource with the uploaded content.

v) DELETE

The DELETE method is used to remove all the current representations of the target resource, which is given by URI.

vi) CONNECT

The CONNECT method is used to establish a tunnel to the server, which is identified by a given URI.

2) Return-URI

The Request-URI is a Uniform Resource Identifier. It is used to identify the resource upon which to apply the request.

Syntax

On the nature of the request, these four options for Request-URI depend.

a) The asterisk “*” is used to show that the request does not apply to a particular resource, but it will apply to the server itself. It is allowed only when the method used does not necessarily apply to a resource.

Example

OPTIONS * HTTP/1.1

b) The absoluteURI form is used only when the request is being made to a proxy. The requested proxy is used to forward the request and return the response.

Example

GET https://tutoraspire.com/WWW/TheProject.html HTTP/1.1

c) The absolute path can’t be empty. If in the original URI, none is present, it must be given as “/”.

d) The authority form is only used by the CONNECT method.

The Resource Identified by a Request

Using the examination of Request-URI and the Host header field, we can determine the exact resource identified by the Internet request.

An origin server must use the following rules for determining the requested resource on an HTTP/1.1 request if the origin server does differentiate based on the host requested.

  1. The host will be part of the Request-URI if Request-URI is an absoluteURI.
  2. The host will be determined by the Host header field value if the Request-URI is not an absoluteURI, and the request includes a header field of the host.
  3. The response MUST be a 400 (Bad Request) error message if the host as determined by rule 1 or 2 is not a valid host on the server.

Request Header Fields

The request-header fields are used to allow the client to pass additional information to the server like the request and the client itself. The request header fields act as request modifiers, with semantics equivalent to the parameters on a programming language method invocation.

Syntax

The name of the request-header field can be extended reliably only in combination with a change in the version of the protocol.


Next TopicHTTP Response

You may also like