CSC322 Question 5

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

HTTP Application Layer Protocol

Document

Introduction

The Hypertext Transfer Protocol (HTTP) is a fundamental protocol used for transmitting hypertext over
the World Wide Web (WWW). It operates at the application layer of the Internet Protocol Suite and
enables the fetching of resources, such as HTML documents. HTTP is a stateless, request-response
protocol which means that each request from a client to server is treated independently without storing
any session data.

Architecture/Components

The architecture of HTTP can be broken down into several components:

1. Client:

 The entity that initiates the request. This is typically a web browser, but it can be any
software or device that sends HTTP requests.

2. Server:

 The entity that receives the request, processes it, and returns the appropriate response.
This is typically a web server hosting the requested resource.

3. Resources:

 The target of the HTTP request, usually in the form of a URL. Resources can be anything
identified by a URL such as HTML files, images, videos, or other data.

4. Requests:

 Comprised of a request line (method, URL, and HTTP version), headers, an optional
message body, and a blank line to indicate the end of headers. Common methods
include GET, POST, PUT, DELETE, and OPTIONS.

5. Responses:

 Comprised of a status line (HTTP version, status code, reason phrase), headers, an
optional message body, and a blank line to indicate the end of headers. Status codes
indicate the result of the request (e.g., 200 OK, 404 Not Found).

6. Headers:

 Key-value pairs that provide additional information about the request or response.
Examples include Content-Type, Content-Length, User-Agent, and Set-Cookie.
HTTP Methods

 GET: Requests a representation of the specified resource. Requests using GET should only
retrieve data.

 POST: Submits data to be processed to a specified resource.

 PUT: Uploads a representation of the specified resource.

 DELETE: Deletes the specified resource.

 HEAD: Same as GET, but it transfers the status line and header section only.

 OPTIONS: Describes the communication options for the target resource

Below is a simple interactive client program in Python that uses the http.client library to fetch a web
page from any web server specified by the user.

You might also like