Back to the 2025 paper

Module II: Browser & Apache Web Server Architecture; Common Protocols

20257m

Explain how a web browser interacts with a web server using the HTTP request-response model.

Worked SolutionAI Assisted

Answer: Browser-Server Interaction via the HTTP Request-Response Model

1. Overview

The HTTP (HyperText Transfer Protocol) request-response model is a client-server communication protocol where the web browser (client) initiates a request, and the web server processes the request and returns an appropriate response over a reliable TCP/IP connection.

+--------------+                                      +--------------+
| Web Browser  |                                      |  Web Server  |
|   (Client)   |                                      |   (Apache)   |
+-------+------+                                      +-------+------+
        |                                                     |
        |  1. DNS Resolution (Domain -> IP Address)           |
        |---------------------------------------------------->|
        |                                                     |
        |  2. TCP 3-Way Handshake (SYN, SYN-ACK, ACK)         |
        |====================================================>|
        |                                                     |
        |  3. TLS/SSL Handshake (For HTTPS connections)       |
        |====================================================>|
        |                                                     |
        |  4. HTTP Request (GET /index.html HTTP/1.1)         |
        |---------------------------------------------------->|
        |                                                     |
        |                   [Server Processes Request & DB]   |
        |                                                     |
        |  5. HTTP Response (200 OK + HTML Body)              |
        |<----------------------------------------------------|
        |                                                     |
        |  6. Sub-resource Requests (CSS, JS, Images)         |
        |<===================================================>|
        |                                                     |
        v                                                     v

2. Step-by-Step Interaction Lifecycle

Step 1: URL Parsing and DNS Lookup

  1. The user types a URL (e.g., https://www.example.com/index.html).
  2. The browser checks local caches (browser cache, OS cache, router cache).
  3. If not found, it queries DNS servers to resolve the domain name into an IP address (e.g., 93.184.216.34).

Step 2: Establishing TCP Connection

  • The browser opens a connection to the server on port 80 (HTTP) or port 443 (HTTPS) using the TCP 3-Way Handshake:
    1. SYN: Client sends synchronization packet.
    2. SYN-ACK: Server acknowledges and responds with SYN.
    3. ACK: Client acknowledges back.

Step 3: TLS/SSL Handshake (For HTTPS)

  • Client and server negotiate cipher suites, authenticate digital certificates, and establish a symmetric session key for encrypted communication.

Step 4: Browser Sends HTTP Request

  • The browser crafts and sends a formatted HTTP request message.
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml
Accept-Language: en-US,en;q=0.9
Connection: keep-alive

Step 5: Server Processing and HTTP Response

  • The web server (e.g., Apache, Nginx) parses the request, executes server-side scripts (PHP/JSP/Servlets), queries databases if necessary, and returns an HTTP response message.
HTTP/1.1 200 OK
Date: Mon, 20 Aug 2026 12:00:00 GMT
Server: Apache/2.4.52
Content-Type: text/html; charset=UTF-8
Content-Length: 1024
Connection: keep-alive

<!DOCTYPE html>
<html>
  <head><title>Example</title></head>
  <body><h1>Welcome to Example!</h1></body>
</html>

Step 6: Rendering and Additional Asset Requests

  • The browser parses the received HTML. As it encounters linked assets (<link rel="stylesheet">, <script src="...">, <img src="...">), it sends parallel HTTP requests over persistent connections (HTTP Keep-Alive / HTTP/2 multiplexing) until the entire page is rendered.

3. Key Components of HTTP Messages

Component Request Message Response Message
Initial Line Request Line (METHOD URL VERSION) Status Line (VERSION STATUS_CODE REASON)
Headers Host, User-Agent, Accept, Cookie Content-Type, Content-Length, Set-Cookie
Empty Line `\r
` separator `\r
` separator
Body (Payload) Form data, JSON payload (for POST/PUT) HTML, CSS, JSON data, or binary image

4. Common HTTP Status Codes

  • 200 OK: Request succeeded.
  • 301 Moved Permanently: Resource redirected to a new URL.
  • 400 Bad Request: Server could not parse the client request.
  • 404 Not Found: Requested URL does not exist.
  • 500 Internal Server Error: Server encountered an unexpected failure.

Similar questions