Member-only story

Anatomy of an HTTP Request

What a raw HTTP request looks like

Patrick Divine
Better Programming
5 min readJul 27, 2019

--

Photo by NASA on Unsplash

An HTTP request defines the following:

  • Method (required) — (Example: GET)
  • Host (required) — (Example: www.bing.com)
  • Path (required) —(Example: /search)
  • HTTP version (required) — (Example: HTTP/2)
  • Headers (optional) — (Example: Content-Type: application/json)
  • Query String (optional) — (Example: ?q=test)
  • Body (optional) — (Example: {“q”: “test”})

HTTP Overview

HTTP is one of the many protocols (strategies of communication) used to transfer data from one machine to another across the internet. It is the protocol that browsers primarily use to communicate with websites.

For instance, when you go to www.wikipedia.org, an HTTP request is created and transmitted to Wikipedia’s servers, which in turn render and transmit an HTTP response back to the browser.

The HTTP protocol is a “text-based protocol”, which means that this strategy uses human-readable characters as its means of communication.

So, as an example, a request to search for “test” on the bing.com website by going to https://www.bing.com/search?q=test looks like this:

--

--

Responses (2)

Write a response