Skip to content

Http Request And Responses

Hardikb19 edited this page Dec 13, 2019 · 1 revision

Here we will be learning about basic GET and POST requests, understanding APIs and using Postman.

What is HTTP?

The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers.

HTTP works as a request-response protocol between a client and a server.

A web browser may be the client, and an application on a computer that hosts a web site may be the server.

Example: A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content.

The various HTTP Methods are:

  • GET
  • POST
  • PUT
  • HEAD
  • DELETE
  • PATCH
  • OPTIONS

We will be dealing only with GET and POST methods.

The Get Method

The GET methods are used to receive a response from a server or API.

The Post Method

The POST method is used to submit an entry to a server, which results in a change in state.

What is HTTP Request?

An HTTP request is made by a client, to a named host, which is located on a server. The aim of the request is to access a resource on the server.

To make the request, the client uses components of a URL (Uniform Resource Locator), which includes the information needed to access the resource. The components of a URL explains URLs.

A correctly composed HTTP request contains the following elements:

  1. A request line.
  2. A series of HTTP headers, or header fields.
  3. A message body, if needed.

Read about HTTP requests in detail

What is HTTP Response?

HTTP Response is the packet of information sent by Server to the Client in response to an earlier Request made by Client. HTTP Response contains the information requested by the Client.

An HTTP response contains:

  1. A status line.
  2. A series of HTTP headers, or header fields.
  3. A message body, which is usually needed.

Read about HTTP responses in detail