0% found this document useful (0 votes)
7 views

Week#4 Python

python removing lists

Uploaded by

asifameerhamza11
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Week#4 Python

python removing lists

Uploaded by

asifameerhamza11
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Week#4

HTTP and Web Servers

Understanding Requests and Responses


Ms.Nosheen Iqbal
26/09/2024
What is HTTP?

 Definition: Hypertext Transfer Protocol (HTTP) is the foundation of data communication on


the web.

 Purpose: It defines how messages are formatted and transmitted, and how web servers
and browsers should respond to various commands.

 Works as a request-response protocol between client and server.

 HTTP/1.1 is the most common version; HTTP/2 and HTTP/3 are faster versions introduced for
efficiency.

 Key Characteristics:

 Stateless protocol: Each request is independent.


The Client-Server Model

 Client:

The user's web browser or application requesting resources (e.g., Chrome, Firefox).

 Server:

The web server that stores or processes the requested resources.

 Communication:

The client sends HTTP requests, and the server sends HTTP responses.

 Example:

Typing a URL in the browser sends a request to the server, which returns a webp
The Client-Server Model

 Definition: A model where clients (browsers, applications) request resources from


servers.

 Diagram:
Structure of an HTTP Request

HTTP Request Components

 Request Line: Method (GET, POST, etc.), URL, HTTP version.

 Headers: Provide additional information about the request (e.g., User-Agent, Host).

 Body: Optional. Data being sent to the server (e.g., form submissions).
Common HTTP Methods

 GET: Retrieve data from the server.

 POST: Send data to the server (e.g., submitting a form).

 PUT: Update or replace existing resources.

 DELETE: Remove a specified resource from the server.

 HEAD: Similar to GET but without the response body (fetches headers).

 PATCH: Apply partial modifications to a resource.


Web Server Software Comparison

 Apache:

 Widely used, flexible configuration.

 Good for smaller-scale applications.

 Nginx:

 High performance, great for handling multiple concurrent connections.

 Often used as a reverse proxy for load balancing.


Structure of an HTTP Response

 Status Line: HTTP version, status code, status message.

 Headers: Information about the response (e.g., Content-Type, Content-Length).

 Body: The actual data (HTML, JSON, images, etc.) returned by the server.
HTTP Status Codes

 1xx (Informational): Request received, continuing process.

 2xx (Success): Request successfully received, understood, and accepted (e.g., 200 OK).

 3xx (Redirection): Further action needed to complete the request (e.g., 301 Moved

Permanently).

 4xx (Client Error): The request contains bad syntax or cannot be fulfilled (e.g., 404 Not

Found).

 5xx (Server Error): The server failed to fulfill a valid request (e.g., 500 Internal Server Error).
Understanding Web Servers

 A web server is software that serves web pages in response to HTTP requests.

 Hosts websites and handles requests for static (e.g., HTML) and dynamic content (e.g.,

PHP, Python scripts).

 Examples: Apache, Nginx, IIS.

 A web server can also act as a reverse proxy, handling traffic between clients and multiple

servers.
The Role of DNS in HTTP Requests

 DNS (Domain Name System): Translates domain names (e.g.,


www.example.com) into IP addresses.

 Process:

 Client requests domain (www.example.com).

 DNS server translates it to an IP (93.184.216.34).

 The HTTP request is then sent to this IP address.


HTTP vs HTTPS

 HTTP:

 Data is sent in plain text.

 Suitable for non-sensitive data.

 HTTPS:

 Encrypts data to ensure privacy.

 Essential for sensitive data like passwords, banking information.

 Uses SSL/TLS for encryption.


Web Server Architecture

 Static Content: Directly served from file storage (e.g., HTML, CSS, JavaScript).

 Dynamic Content: Generated on-the-fly using server-side scripts (e.g., PHP, Python).

 Database Connection: Web servers often interact with databases (e.g., MySQL) to retrieve or store
data
Conclusion

 HTTP is the backbone of web communication, facilitating data transfer between clients and
servers.

 Web servers play a critical role in delivering both static and dynamic content.

 The evolution of HTTP, from HTTP/1.1 to HTTPS, has enhanced the speed, security, and
performance of the web.

You might also like