The Foundation of Web Systems

HTTP is the protocol for web communication. REST uses resource-oriented URLs and verbs like GET, POST, PUT, and DELETE.

Every interaction between a browser and a server follows this standardized stateless request-response paradigm.

The Anatomy of an HTTP Transaction

An HTTP request consists of three essential segments:

  1. Request Line: The method verb, target URI path, and protocol version (e.g., GET /api/articles/ HTTP/1.1).
  2. Headers: Metadata key-value pairs specifying content types, authentication tokens, caching directives, and cookies.
  3. Body (Payload): Optional payload data, typically formatted in JSON for RESTful endpoints.

Core HTTP Verbs and Idempotency

  • GET: Retrieve resource representations. Safe and idempotent — does not modify server state.
  • POST: Create new subsidiary resources or submit form data. Neither safe nor idempotent.
  • PUT: Completely replace an existing resource identified by URI. Idempotent.
  • PATCH: Apply partial modifications to an existing resource.
  • DELETE: Remove the identified resource. Idempotent.

Standard HTTP Status Codes

Servers return 3-digit status codes indicating the result of the request:

  • 200 OK / 201 Created: Request processed successfully.
  • 301 Moved Permanently / 302 Found: Resource relocation and redirects.
  • 400 Bad Request / 401 Unauthorized / 403 Forbidden / 404 Not Found: Client-side errors.
  • 500 Internal Server Error / 502 Bad Gateway: Server-side runtime failures.

REST Architectural Constraints

Roy Fielding established that true REST services must maintain client-server separation, remain completely stateless across interactions, leverage standard HTTP cacheability, and utilize uniform resource identifiers (URIs) representing nouns rather than remote procedure verbs.