---
title: "HTTP request served by server"
subject: "Computer Networks and Security"
chapter: 6
key: "semester_7/computer_networks_and_security:http-request-served"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/http-request-served
site: BCT Engineering
---

# HTTP request served by server

Computer Networks and Security · Chapter 6: Application Layer

- Asked in: 2069 Chaitra, 2+6 marks
- Video: [How an HTTP Request Gets Served - In Great Detail](https://www.youtube.com/watch?v=hWyBeEF3CqQ) — Dave's Garage
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/http-request-served
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-6

## Question

What is HTTP protocol? With an example explain how a request initiated by an HTTP client is served by an HTTP server.

## Short answer

HTTP is a stateless client-server protocol over TCP, using port 80 or 443. A client sends a request line like GET /index.html HTTP/1.1 with headers, and the server replies with a status line, headers, and body, such as HTTP/1.1 200 OK with the HTML page.

## Answer

**HTTP (HyperText Transfer Protocol)** is the application-layer protocol of the World Wide Web. It follows the client-server model: a client (browser) sends a request and a server sends a response. It uses TCP, port 80 (HTTPS, port 443). HTTP is **stateless**: the server does not remember earlier requests (cookies add state).

#### Example: user opens http://www.abc.com/index.html
1. The browser asks DNS for the IP address of www.abc.com (say 10.1.1.5).
2. The browser opens a **TCP connection** to 10.1.1.5 port 80 (three-way handshake).
3. The browser sends the **request**:
```text
GET /index.html HTTP/1.1
Host: www.abc.com
User-Agent: Mozilla/5.0
Accept: text/html
Connection: keep-alive
```
4. The server parses the request line, finds the file, and sends the **response**:
```text
HTTP/1.1 200 OK
Date: Thu, 08 Oct 2026 10:00:00 GMT
Server: Apache
Content-Type: text/html
Content-Length: 2048

<html> ... </html>
```
5. The browser reads the HTML. For each embedded object (images, CSS), it makes more requests, over the same connection if persistent (HTTP/1.1).
6. The connection is closed (or kept for the next request) and the page is displayed.

```text
Client                    Server
  |---- TCP handshake ---->|
  |---- GET /index.html -->|
  |<--- 200 OK + HTML -----|
  |---- GET /logo.png ---->|
  |<--- 200 OK + image ----|
```

#### Parts of a message
- **Request:** request line (method, URL, version), headers, blank line, optional body. Methods: GET, POST, HEAD, PUT, DELETE.
- **Response:** status line (version, code, phrase), headers, blank line, body.
- **Status codes:** 1xx informational, 2xx success, 3xx redirection, 4xx client error (404), 5xx server error (500).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. HTTP being stateless means:
   A. Server remembers earlier requests
   B. Server does not remember earlier requests (cookies add state)
   C. It has no response
   D. It uses UDP
   Answer: B. Each request is independent. (Key point: Stateless)

2. Before sending a GET request, the browser must:
   A. Resolve the name by DNS and open a TCP connection
   B. Send a response
   C. Close TCP
   D. Ask DHCP
   Answer: A. DNS then TCP handshake, then HTTP request. (Key point: Order of steps)

3. 4xx status codes indicate:
   A. Success
   B. Redirection
   C. Client error
   D. Server error
   Answer: C. 4xx client error; 5xx server error. (Key point: Status classes)

## Related in Computer Networks and Security

- [Server before client; TCP reliability](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Atcp-server-before-client-reliability) — Computer Networks and Security, chapter 5, asked 2×
- [Client-server vs peer-to-peer](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aclient-server-vs-p2p) — Computer Networks and Security, chapter 1
- [Features of client/server architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aclient-server-features) — Computer Networks and Security, chapter 1

## Related in other subjects

- [HTTP request methods; web server and virtual hosting](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Ahttp-methods-config-virtual-hosting) — Internet and Intranet, chapter 4
- [Client-side versus server-side scripting](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Aclient-vs-server-side-scripting) — Web Technology, chapter 3, asked 3×
- [Short note: Client-Server and Master-Slave](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Ashort-note-client-server-master-slave) — Big Data Technologies, chapter 1
- [Client/server architecture and FTP operation](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Aclient-server-ftp) — Internet and Intranet, chapter 3
