Course contentsShow
← Computer Science
Lesson 1515 of 2,87235. Application Layer ProtocolsFree lesson

HTTP Request Structure

Breaking down HTTP request components: method, URI, headers, and body.

HTTP Request Structure

What you'll learn: How HTTP requests are organized into four key parts that tell a server exactly what a client wants.

Breaking Down an HTTP Request

When your browser (or any HTTP client) wants to fetch a webpage or submit data, it sends a structured HTTP request to a server. Think of it like filling out a detailed form at a post office: you specify what you want, where it should go, any special handling instructions, and optionally include a package.

Every HTTP request has four main components, though the last one is optional:

1. Request Method (Verb)

The method declares what action you want the server to perform. Common examples include:

  • GET – retrieve a resource
  • POST – submit data to the server
  • PUT – update a resource
  • DELETE – remove a resource

2. URI (Uniform Resource Identifier)

The URI specifies the exact resource path on the server. For example: /index.html or /api/users/123. This tells the server which file or endpoint you're targeting.

3. Headers

Headers provide metadata about the request—like extra instructions or context. Examples:

  • Host: www.example.com (required in HTTP/1.1)
  • User-Agent: Mozilla/5.0 (identifies the client)
  • Accept: text/html (preferred response format)

4. Body (Optional)

The body contains data being sent to the server, typically with POST or PUT requests. For example, form data or JSON payload. GET requests usually have no body.

Analogy

Imagine ordering at a restaurant: the method is whether you're ordering, paying, or canceling; the URI is the menu item number; headers are dietary preferences or instructions; the body is any customization details.

Key Takeaway: HTTP requests consist of a method (what to do), URI (where), headers (contextual info), and an optional body (data payload)—structured precisely so servers know how to respond.