Assignment-3
Assignment-3
Q.1) Give brief details about HTTP. What is the difference between HTTP and HTTP
1.1?
Ans)
HTTP, or Hypertext Transfer Protocol, is a communication protocol used for transferring data
between web browsers and web servers. It follows a request-response model and operates over
port 80. It is stateless, meaning each request is independent and does not retain session
information.
The difference between HTTP and HTTP/1.1 lies in several aspects. HTTP (1.0) opens a new
connection for each request, whereas HTTP/1.1 supports persistent connections, allowing
multiple requests over the same connection. This makes HTTP/1.1 faster as it reduces the
overhead of repeatedly opening and closing connections. HTTP/1.1 also supports pipelining,
which allows multiple requests to be sent before receiving responses, improving efficiency.
Additionally, HTTP/1.1 introduces better caching mechanisms, making resource loading more
efficient. Another key difference is that HTTP (1.0) does not require a Host header, while
HTTP/1.1 makes it mandatory, allowing multiple domains to be hosted on a single server.
Capturing HTTP request packets for any URL can be done using various tools like Wireshark,
tcpdump, or browser developer tools. Here’s a general step-by-step guide using Wireshark:
tcp port 443 (for HTTPS, but the content will be encrypted) ```
- Alternatively, you can capture packets for a specific website by filtering the IP address:
- Use the Filter bar to search for `http.request` or `tcp.stream eq X` to follow a request-response
session.
---
- Chrome: Press `F12` or `Ctrl + Shift + I`, then go to the Network tab.
- Headers
- Response details
Objective: Analyze how HTTP works by capturing and studying HTTP request and
response messages.
Tasks:
○ Request Headers
○ Response Headers
○ HTML Content
Ans)
The request method defines the action the client wants the server to perform. It appears in the
first line of an HTTP request.
Request headers provide metadata about the request. They help the server understand what
the client expects.
A URL (Uniform Resource Locator) specifies the resource location on a web server. It may
contain parameters that pass additional data.
Parts of a URL:
```
https://www.example.com/search?q=Wireshark&page=2
```
1. Status Code:
2. Response Headers:
Examples:
3. HTML Content:
HTTPS
Task 5 : How HTTP communication takes place.
HTTP communication involves a client, typically a web browser, making a request to a server,
and the server responding to that request. The process begins when a user enters a URL into a
browser, which then sends an HTTP request to the server hosting the website specified in the
URL. This request includes information such as the HTTP method (like GET or POST), headers,
and sometimes a body containing additional data.
Upon receiving the request, the server processes it and sends back an HTTP response. The
response includes a status code indicating the outcome of the request, headers with metadata
about the response, and the body containing the requested data, such as HTML, images, or
other resources. The status code helps the client understand whether the request was
successful or if there was an error. For example, a status code of 200 indicates success, while a
404 code indicates that the requested resource was not found.
HTTP is a stateless protocol, meaning each request and response is independent of others. The
server does not retain information about previous requests unless mechanisms like cookies or
sessions are used. This statelessness simplifies the protocol but can complicate tasks that
require maintaining state across multiple requests.
HTTP operates on top of the TCP/IP protocol stack, using port 80 by default, though other ports
can be used as well. It is designed to be generic and can be extended to handle various types of
data and interactions beyond just HTML documents.
HTTP communication is foundational to the World Wide Web, enabling the exchange of
information between clients and servers in a standardized way. It supports various methods for
data transfer, including GET for retrieving resources and POST for submitting data to be
processed by the server.
HTTP is distinct from HTTPS, which adds encryption and security to the communication process,
making it more suitable for transmitting sensitive information. However, the basic structure of
request and response remains the same in both protocols.