Web Fundamentals: HTTP Deep Dive

Site Admin · 11 Sep 2026 · 6 views

HTTP Is a Request and Response Protocol

HTTP, the HyperText Transfer Protocol, defines how clients and servers exchange messages. A client sends a request line with a method, a path, and the protocol version, followed by headers and an optional body. The server replies with a status line, headers, and an optional body. HTTP is stateless: each request is independent, so servers use cookies, sessions, or tokens to remember you across requests.

HTTP Methods

The method describes the intention of the request.

  • GET - fetch a resource without changing it.
  • POST - send data to create something new.
  • PUT - replace an existing resource in full.
  • PATCH - apply a partial update.
  • DELETE - remove a resource.
GET /books/java HTTP/1.1
Host: example.com
Accept: application/json

GET requests are safe and idempotent, meaning they can be repeated without side effects. GET should never change server state; use POST for actions that create or modify data.

Status Codes

The server responds with a three-digit status code grouped by meaning.

  • 2xx success - 200 OK is the most common.
  • 3xx redirection - 301 moved permanently, 302 found temporarily.
  • 4xx client error - 404 not found, 401 unauthorized, 403 forbidden.
  • 5xx server error - 500 internal server error means the server blew up.

Headers Carry Context

Headers are key-value pairs that pass metadata. Request headers include Accept, which lists the formats the client prefers, and Authorization, which carries credentials. Response headers include Content-Type, which says whether the body is HTML, JSON, or an image, and Cache-Control, which tells browsers how long to reuse the response.

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Cache-Control: max-age=3600

You can watch all of this in your browser developer tools under the Network tab. Picking apart real requests and responses is the fastest way to make HTTP feel concrete.

Key Points

  • HTTP messages have a start line, headers, and an optional body.
  • GET, POST, PUT, PATCH, and DELETE express different intentions.
  • Status codes are grouped by meaning into five classes.
  • Headers such as Content-Type and Cache-Control shape how responses behave.
Share this post:

Comments (0)

Please login or register to comment.