Computer Networks and Internet Basics (9hrs) · Computer Fundamentals & Emerging Technologies

Hypertext Transfer Protocol (HTTP)

Watch lectures

Hypertext Transfer Protocol (HTTP)

1. Definition

HTTP (Hypertext Transfer Protocol) is the application-layer request–response protocol of the World Wide Web. A client (browser, app, crawler) sends a request for a resource identified by a URL; a server replies with a response containing a status code, headers and the resource itself (HTML, CSS, JavaScript, images, video, JSON). It is stateless — each request is independent and carries everything the server needs — and it normally runs over TCP port 80, while HTTPS is HTTP over TLS on port 443, giving confidentiality, integrity and server authentication.

2. The Request–Response Cycle

   BROWSER                                                         WEB SERVER
      │  1. resolve www.pyqdeck.com → IP (DNS)                          │
      │  2. TCP three-way handshake (port 443)                          │
      │  3. TLS handshake (certificate, keys)                          │
      │  ── HTTP REQUEST ─────────────────────────────────────────────► │
      │  ◄─────────────────────────────────────── HTTP RESPONSE ─────── │
      │  4. parse HTML → request CSS/JS/images (more requests)         │
      │  5. render the page, cache resources                           │

Sample request:

GET /papers/cse-sem1 HTTP/1.1
Host: pyqdeck.com
User-Agent: Mozilla/5.0 (Android 14)
Accept: text/html,application/xhtml+xml
Accept-Language: en-IN
Cookie: session=abc123

Sample response:

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 15400
Cache-Control: max-age=3600
Set-Cookie: session=abc123; Secure; HttpOnly

<!DOCTYPE html><html> ...

3. HTTP Methods

Method Purpose Safe? Idempotent?
GET Retrieve a resource; parameters in the URL Yes Yes
HEAD Same as GET but headers only (check size/existence) Yes Yes
POST Submit data (form, upload) creating a new resource No No
PUT Create or replace a resource at a known URL No Yes
PATCH Partially modify a resource No No
DELETE Remove a resource No Yes
OPTIONS Ask which methods/features the server supports (used by CORS) Yes Yes
TRACE / CONNECT Diagnostic echo / tunnel (used for HTTPS proxies) — —

4. Status Codes (memorise the families and the classics)

Range Meaning Examples
1xx Informational 100 Continue
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, 429 Too Many Requests
5xx Server error 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout

5. Important Headers

Request: Host (which site on a shared server), User-Agent (browser/device), Accept and Accept-Encoding (content types and compression the client supports), Cookie, Authorization (token/credentials), Referer, If-None-Match (cache validation), Connection: keep-alive.
Response: Content-Type and Content-Length, Set-Cookie, Cache-Control / Expires / ETag (caching rules), Last-Modified, Location (for redirects), Server, Strict-Transport-Security.

6. State, Sessions and Caching

  • HTTP is stateless, so the server remembers nothing between requests. State is added by cookies (Set-Cookie → later Cookie headers), server-side sessions, or tokens/JWT in the Authorization header.
  • Caching avoids re-downloading: Cache-Control, ETag/If-None-Match and Last-Modified/If-Modified-Since let the browser reuse a copy, and the server can answer with 304 Not Modified.
  • Compression (gzip, br) shrinks text responses; content negotiation picks the best format/language.
  • HTTPS wraps all of this in TLS: an RSA/ECDHE handshake, a signed certificate proving the server's identity, and symmetric encryption of the whole exchange.

7. HTTP Versions

Version Key change
HTTP/1.0 One request per TCP connection — a new connection for every object
HTTP/1.1 Persistent connections (keep-alive), pipelining, chunked transfer, virtual hosts (Host), better caching
HTTP/2 Binary framing, multiplexed streams over one TCP connection (removes most head-of-line blocking), header compression (HPACK), server push, prioritisation
HTTP/3 Runs over QUIC (UDP) — faster connection setup (0-RTT), no TCP head-of-line blocking, better on lossy mobile networks

8. Advantages and Limitations

Advantages Limitations
Simple, text-based, human-readable with standard tools Statelessness requires cookies/sessions for state
Universal — every browser, server and device supports it Plain HTTP is not encrypted — sniffing and tampering are possible
Extensible through headers, methods and content types Header overhead is large for small payloads
Stateless and cacheable → highly scalable across servers HTTP/1.1 head-of-line blocking limits parallel requests (fixed in 2/3)
Forms the base of REST APIs, streaming and the whole web No built-in push in 1.1; server push only from HTTP/2

9. Exam Points

  • Define HTTP; explain the request–response model with an example request and response — 5-7 marks, very frequent.
  • Explain the HTTP methods (GET, POST, PUT, DELETE, HEAD) and the difference between GET and POST — 5 marks, almost certain.
  • Explain HTTP status code classes with two examples each (or list any five codes) — 5 marks, very frequent.
  • What does "HTTP is stateless" mean? How is state maintained? — 3-5 marks.
  • Differentiate HTTP and HTTPS; how does HTTPS work? — 5 marks.
  • Compare HTTP/1.1, HTTP/2 and HTTP/3 — 3-5 marks.
  • Which port does HTTP/HTTPS use? — 2 marks.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Computer Fundamentals & Emerging Technologies modules