Application Layer · Computer Networks

SVGVector Architecture Diagram (SVG)
COMPUTER NETWORKS · Module 5 · Application Layer★ High PriorityIT Sem 6 · Code 100602HyperText Transfer Protocol (HTTP)MNEMONICHTTP = Request + Response, text based, STATELESS, TCP port 80.Status codes: 1xx info, 2xx OK, 3xx move, 4xx you, 5xx server.Core BreakdownOverviewHTTP is the Web's application-layer protocol: a client sends a request, the server sends a response.Runs over TCP (port 80; HTTPS uses TLS on 443). Messages are readable ASCII text.StatelessThe server keeps no memory of earlier requests: each request is independent.State is added with cookies, sessions or tokens, e.g. for logins and shopping carts.RequestRequest line (method, URL, version), header lines, a blank line, and an optional body.Example: GET /index.html HTTP/1.1 followed by Host: www.site.com.ResponseStatus line (version, code, phrase), header lines, a blank line, then the body.Headers such as Content-Type and Content-Length describe the body.MethodsGET (read), HEAD (headers only), POST (send data), PUT (replace), DELETE, OPTIONS.Safe = no change on the server (GET, HEAD). Idempotent = same result if repeated (GET, PUT, DELETE).Status Codes200 OK · 301 Moved Permanently · 304 Not Modified · 400 Bad Request · 404 Not Found.500 Internal Server Error · 503 Service Unavailable. First digit tells the class.ConnectionsHTTP/1.0: non-persistent, a new TCP connection for every object.HTTP/1.1: persistent by default, with pipelining; HTTP/2 multiplexes streams; HTTP/3 uses QUIC.CookiesServer sends Set-Cookie; the browser returns it in a Cookie header on later requests.Lets a stateless protocol recognise a user across requests (sessions, tracking).Diagram: HTTP ExchangeClientbrowserServerport 80 / 443GET /index.html HTTP/1.1200 OK + headers + bodyRequestRequest line: METHOD URL VERSIONHeaders: Host, User-Agent, ...(blank line)Body (POST/PUT only)ResponseStatus line: VERSION CODE PHRASEHeaders: Content-Type, Length(blank line)Body: HTML, image, JSON1xx info2xx OK3xx redirect4xx client5xx serverSafe: GET, HEAD, OPTIONS · Idempotent: GET, PUT, DELETENot idempotent: POST (creates a new resource each time)200 OK · 301 moved · 304 not modified · 404 not found500 server error · Cookies add state to a stateless protocol⚠️ Exam Traps & Viva Favorites① Is HTTP stateful?No: HTTP is STATELESS. The server forgetseach request. Cookies and sessions addstate on top of it.② GET vs POST?GET reads data (safe, idempotent, data inthe URL). POST sends data in the body andis not idempotent.③ Persistent vs non-persistent?HTTP/1.0 opens a new TCP link per object.HTTP/1.1 keeps it open (persistent), soit saves RTTs and handshakes.Tip: 4xx client · 5xx serverMaster Revision Table(learn it row by row!)ItemValueMeaningSafe / IdempotentNoteGETReadFetch a resourceSafe, idempotentData in the URLPOSTSendSubmit data to processNeitherData in the bodyPUTReplaceCreate or replace a resourceIdempotentNot safeDELETERemoveDelete a resourceIdempotentNot safe200 / 404 / 500StatusOK / not found / server errorn/a2xx / 4xx / 5xxHTTP/1.0 vs 1.1VersionNon-persistent vs persistentn/a2 uses multiplexingQUICK FACTSPorts: HTTP 80 · HTTPS 443 · Transport: TCP · Stateless text protocolClasses: 1xx info · 2xx success · 3xx redirect · 4xx client error · 5xx server errorVersions: 1.0 non-persistent · 1.1 persistent · 2 multiplexing · 3 QUIC (UDP)VERIFIED★ Golden rule: HTTP is stateless request-response; cookies add the memory.

HyperText Transfer Protocol (HTTP)


1. Overview and Design Principles

The HyperText Transfer Protocol (HTTP) (RFC 2616 / 7230) is the foundational request-response application protocol that powers the World Wide Web.

Key Architectural Traits:

  1. Client-Server Model: A client (web browser) initiates a connection to an HTTP server and sends a request; the server processes the request and returns a response.
  2. Underlying Transport: Operates over TCP Port 80 (Unencrypted HTTP) and TCP Port 443 (Encrypted HTTPS over TLS).
  3. Stateless Protocol: The server retains zero memory (state) of previous requests from the same client. Each transaction is processed completely independently.
  4. State Management via Cookies: To maintain shopping carts, login states, and user sessions, web servers use Cookies (Set-Cookie response header and Cookie request header).

2. HTTP Message Formats

HTTP messages are human-readable, plain ASCII text structures:

MermaidDiagram
Rendering diagram…

3. HTTP Methods and Idempotency

SVGVector Architecture Diagram (SVG)
METHOD ACTION SAFE? IDEMPOTENT? GET Retrieve representation of data Yes Yes POST Submit data / create new resource No No PUT Replace or create at exact URI No Yes DELETE Delete resource at exact URI No Yes HEAD Same as GET but returns headers only Yes Yes OPTIONS Query supported methods by server Yes Yes
  • Safe Method: A method that does not alter server state (read-only: GET, HEAD).
  • Idempotent Method: Executing the request multiple times produces the exact same server state as executing it once (GET, PUT, DELETE).

4. HTTP Status Code Categories

Status codes are 3-digit integers returned by the server:

SVGVector Architecture Diagram (SVG)
CODE CATEGORY COMMON EXAMPLES 1xx Informational 101 Switching Protocols (WebSockets upgrade) 2xx Success 200 OK, 201 Created, 204 No Content 3xx Redirection 301 Moved Permanently, 302 Found, 304 Not Modified 4xx Client Error 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 408 Request Timeout

5. Evolution: HTTP/1.0 vs. HTTP/1.1 vs. HTTP/2 vs. HTTP/3

MermaidDiagram
Rendering diagram…
  1. HTTP/1.0 (Non-Persistent): Every resource requires opening and closing a separate TCP connection. If a webpage contains 50 images, 50 full TCP handshakes are executed!
  2. HTTP/1.1 (Persistent): Introduced Connection: keep-alive (default), keeping the TCP connection open for subsequent requests. Supports pipelining, but suffers from Application Head-of-Line Blocking (request #2 cannot complete until request #1 finishes).
  3. HTTP/2: Replaces text with a Binary Framing Layer. Fully multiplexes multiple request/response streams concurrently over a single TCP connection, adds HPACK header compression, and supports Server Push.
  4. HTTP/3: Built on QUIC over UDP (Port 443), eliminating TCP-level packet loss Head-of-Line blocking and enabling 0-RTT handshakes.

Frequently Asked Questions

QWhy is HTTP described as a stateless protocol? How is state maintained?

HTTP servers do not retain information regarding past client transactions. State is maintained using HTTP Cookies and session tokens: the server sets a cookie in the response header (Set-Cookie), which the client sends back in all future request headers (Cookie).

QCompare Non-Persistent and Persistent HTTP connections.

Non-persistent HTTP (HTTP/1.0) creates and tears down a separate TCP connection for every single referenced web object, consuming 2 RTTs2\text{ RTTs} per object. Persistent HTTP (HTTP/1.1) reuses a single open TCP connection to fetch multiple objects sequentially.

QWhat is the difference between HTTP/1.1 and HTTP/2?

HTTP/1.1 uses text-based formatting and processes requests sequentially (suffering Head-of-Line blocking). HTTP/2 uses binary framing and multiplexes multiple independent request streams simultaneously over a single TCP connection without blocking.

QWhat is the difference between a safe and an idempotent HTTP method?

A safe method (GET, HEAD) does not change server state. An idempotent method (GET, PUT, DELETE) gives the same server state whether it is executed once or many times. POST is neither.

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Computer Networks modules