Application Layer: The World Wide Web and HTTP Protocol
Overview of the World Wide Web and HTTP
World Wide Web (WWW) Definition: An information system where documents and other resources are identified by Uniform Resource Locators (URLs), interlinked by hypertext, and accessed over the Internet.
Components of Web Architecture:
URL (Uniform Resource Locator): Uniquely identifies web resources.
Host Name: Specifies the host server domain (e.g.,
www.unt.edu).Path Name: Specifies the path location of the file on the host server (e.g.,
/index.html).Example full URL:
www.unt.edu/index.html.

HTML (HyperText Markup Language): Language for creating hypertext documents.
HTTP (HyperText Transfer Protocol): Application-layer protocol used for transferring web resources across the Internet.
Web Page Composition and Objects:
A web page consists of a base HTML file that typically references and hyperlinks other web objects.
Each web object is individually addressable by its unique URL.
Web objects can be HTML files, images, scripts, audio, video, etc.
Objects referenced on a single page can be stored on the same web server or across different web servers.
Web Browsers: Procure web pages and objects from web servers and display them to users.
Historical Background: Sir Tim Berners-Lee invented the World Wide Web at CERN in .
Core Technical Characteristics of HTTP
Transport Protocol: HTTP uses TCP (Transmission Control Protocol) at the transport layer.
Server listens for incoming connections on port .
Client initiates a TCP connection handshake, exchanges HTTP messages, and closes the connection.
Protocol Specifications:
HTTP/1.0: Specified in RFC 1945.HTTP/1.1: Specified in RFC 2616.Text Format: ASCII (human-readable) text format.
Message Types: Standardized into two message types: request and response.
Client-Server Model:
Clients: Request and receive web objects via HTTP and display them.
Servers: Store and send web objects in response to HTTP requests.
Statelessness:
HTTP is a stateless protocol: the server maintains no information about past client requests.
Rationale: Protocols that maintain state tend to be complex, requiring intricate mechanisms to track state across server crashes, network disruptions, or client failures.
HTTP Request Message Format and Structure
Request Structure Breakdown:
Request Line: Contains method, space (
sp), URL, space (sp), version, carriage return (cror\r), and line feed (lfor ).Header Lines: Formatted as
header field name:, space (sp),value, carriage return (cr), and line feed (lf).Blank Line: A line consisting of carriage return and line feed (
cr lfor\r) at the start of the line indicates the end of the header lines.Entity Body (Message Body): Payload area containing data (used with methods like
POSTorPUT).
Concrete Request Message Example:
GET /index.html HTTP/1.1\r
Host: www.unt.edu\r
User-Agent: Mozilla/5.0 (Macintosh; MacOS X 15.6.1) Chrome/144.0.7559.110\r
Accept: text/html,application/xhtml+xml,image/webp,image/apng\r
Accept-Language: en-us,en\r
Connection: keep-alive\r
\r\n
Request Line:
GET /index.html HTTP/1.1Header Lines: Include
Host,User-Agent,Accept,Accept-Language, andConnectionheaders.End of Headers: Marked by an isolated \r
Key Methods of HTTP Requests
GET Method:
Requests data/resources from the server.
User data can be embedded directly in the URL query field following a
?character.Example:
www.google.com/search?q=unt
POST Method:
Used for transmitting web form data filled out by a user.
Data is included in the entity body of the request message rather than in the URL.
Server returns a dynamic web page based on user inputs provided in the form.
PUT Method:
Uploads a new object to the server.
Completely replaces the file existing at the specified URL with the content provided in the entity body of the
PUTrequest.
HEAD Method:
Requests the server to respond with headers pertaining to the specified URL only (omits the entity body).
Commonly used for debugging, testing resource existence, or checking metadata.
DELETE Method:
Deletes a specified object/file hosted at the target URL on the server.
Not commonly supported or allowed on standard public web servers due to security concerns.
HTTP Response Message Format and Structure
status line -> HTTP/1.1 200 OK
- Date: Wed, 2 Sep 2026 18:53:20 GMT
| Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k fips
Header lines ---| PHP/7.4.9 Perl/v5.16.3
| Last-Modified: Tue, 1 Sep 2026 10:57:50 GMT
| Content-Length: 2651
| Content-Type: text/html; charset=UTF-8
- \r\n
Requested HTML File-> data data data data data ...Response Structure Breakdown:
Status Line: Contains protocol version, space
sp), status code, spacesp), status phrase, carriage returncr), and line feedlf).Header Lines: Formatted as
header field name:, spacesp),value, carriage returncr), and line feedlf).Blank Line: Carriage return and line feed
cr lfor `\r`) indicating the end of response headers.
* Entity Body: Contains the requested resource file/data (e.g., HTML data).
*

Standard HTTP Response Status Codes
1XX Informational Status Codes:
100: Continue101: Switching Protocols102: Processing
2XX Success Status Codes:
200: OK201: Created202: Accepted203: Non-authoritative Information204: No Content205: Reset Content206: Partial Content
3XX Redirectional Status Codes:
300: Multiple Choices301: Moved Permanently302: Found303: See Other304: Not Modified305: Use Proxy307: Temporary Redirect308: Permanent Redirect
4XX Client Error Status Codes:
400: Bad Request401: Unauthorized402: Payment Required403: Forbidden404: Not Found
5XX Server Error Status Codes:
500: Internal Server Error501: Not Implemented502: Bad Gateway503: Service Unavailable504: Gateway Timeout505: HTTP Version Not Supported506: Variant Also Negotiates507: Insufficient Storage
Common HTTP Message Headers
Request Headers:
User-Agent: Information about the client browser software and host platform.Accept: Types of media/pages the client can handle.Accept-Charset: Character sets acceptable to the client.Accept-Encoding: Encodings acceptable to the client.Accept-Language: Natural languages acceptable to the client.Host: The server's DNS host name.Authorization: Credentials list for client authentication.Cookie: Sends a previously set HTTP cookie back to the server.
Response Headers:
Server: Information about server software and environment.Content-Encoding: Encoding algorithm applied to content (e.g.,gzip).Content-Language: Natural language of the document content.Content-Length: Length of payload/page in bytes.Content-Type: MIME type of page/resource.Last-Modified: Time and date the resource was last modified.Location: Redirect command instructing the client browser to request a different URL.Accept-Ranges: Indicates server support for byte-range requests.Set-Cookie: Directs the client browser to save an HTTP cookie.
Headers Applicable to Both Requests and Responses:
Date: Date and time the message was sent.Upgrade: Protocol the sender wishes to switch to.
Real-World Web Problems and Evolution of HTTP
Conditional GET (Web Caching Optimization):
Goal: Prevent unnecessary transmission of objects over the network if the client already possesses an up-to-date cached copy, saving bandwidth and network overhead.
Mechanism:
Client sends a
GETrequest containing anIf-Modified-Since: <date>header specifying the timestamp of the cached copy.Server checks whether the resource was modified after
<date>.If object was NOT modified: Server responds with
HTTP/1.0 304 Not Modifiedcontaining an empty message body.If object WAS modified: Server responds with
HTTP/1.0 200 OKfollowed by the requested object payload.
Connection Management: Non-Persistent vs Persistent HTTP:
Non-Persistent HTTP (
HTTP/1.0):Step-by-step transaction sequence for accessing a URL (e.g.,
www.unt.edu/index.htmlcontaining text, images, and videos):HTTP client initiates a TCP connection to the HTTP server at
www.unt.eduon port .HTTP server waiting at port accepts the TCP connection and notifies the client.
HTTP client sends an HTTP request message (containing the URL
index.html) into the socket.HTTP server receives the request, forms a response containing
index.html, and sends it into its socket.HTTP client receives the response containing the HTML file and displays it. Upon parsing, it identifies references to embedded image and video objects.
HTTP server closes the TCP connection.
HTTP client terminates its TCP connection. It then repeats steps 1, 3, and 5 independently for every referenced object.
Performance Metrics (Round Trip Time - RTT):
RTT: Time required for a small packet to travel from client to server and back.
TCP Connection Handshake Latency: .
HTTP Request and Response Header Latency: .
Formula for response time per object:
Shortcomings of Non-Persistent HTTP:
Incurs overhead per object.
Causes significant Operating System (OS) overhead due to opening and closing distinct TCP connections for every single object.
Led browsers to open multiple TCP connections in parallel to fetch objects, adding network stress.
Persistent HTTP (
HTTP/1.1):Server leaves the TCP connection open after sending its response.
Subsequent HTTP messages between the same client and server are transmitted across the pre-existing open connection.
Client sends requests immediately upon encountering references to web objects.
Performance advantage: Response time drops close to for all referenced objects after the initial object, cutting average delivery time approximately in half.
