1 HTTP
1 HTTP
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
What's HTTP? What's HTTP?
HTTP/ . OK Content-Type: text/html; charset=UTF-!
HTTP (Hyper Text Transfer Protocol) is the protocol used when you access any website through HTTP is a message from a client to the server.
If the user clicks the hyperlink below:
your browser <!DOCTYPE html>
a href="https://www.example.com">Visit <html>
The HTTP request message is sent as: <head>
HTTP/1.1 and HTTP/2 are the most prevalent
GET / HTTP/1.1 Host: www.example.com <title>Welcome to Example.com</title>
versions used on the web today.
</head>
The choice of which version to use depends on the <body> <h >Welcome to Example.com</h >
The response includes an HTML page
web server's support and the specific <p>This is an example website.</p>
(text/html) that the browser can render.
requirements of the application or website. </body>
</html>
DIS Scholar year 2023/2024 UMBB 01 DIS Scholar year 2023/2024 UMBB 02
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
What's HTTP? How URLs work?
HTTP requests and responses are easy to read and understand.
Here is an example of what an HTTP request and response might look like:
Scheme It indicates the protocol being used, such as "http" for unencrypted HTTP or "https" for secure
HTTP. For example, "http" in "http://www.examplecat.com" or "https" in
"https://www.examplecat.com".
Domain This part specifies the server or domain where the resource is located. In the examples above,
"www.examplecat.com" is the domain or host.
Port It's an optional component that specifies the port number to use for the connection. If omitted
(optional)
(deleted), the default ports are 80 for HTTP and 443 for HTTPS.
DIS Scholar year 2023/2024 UMBB 03 DIS Scholar year 2023/2024 UMBB 04
07/10/2023
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
How URLs work? How URLs work? (examples)
DIS Scholar year 2023/2024 UMBB 05 DIS Scholar year 2023/2024 UMBB 06
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Requests Requests
Anatomy of an HTTP requests Anatomy of an HTTP requests
a method (Get, Post, or something else) while HTTP POST requests often do
DIS Scholar year 2023/2024 UMBB 07 DIS Scholar year 2023/2024 UMBB 08
07/10/2023
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Requests Requests
Request methods Request methods
Every HTTP request has a method, which is the first element in the first line of the request.
GET The GET method is used to request data from a specified resource. It retrieves data without
causing any side effects on the server or altering the resource. GET requests are typically used
for reading information.
There are 9 standard HTTP methods. In practice, about 80% of the time, you will primarily use POST and GET
POST The POST method is used to submit data to be processed to a specified resource. It can create
new resources, update existing ones, or perform other actions that may have side effects on the
server.
PUT The PUT method is used to update or replace an existing resource at a specified URI with a new
representation.
DIS Scholar year 2023/2024 UMBB 09 DIS Scholar year 2023/2024 UMBB 10
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Requests Requests
Request methods Request methods
DELETE The DELETE method is used to request the removal of a resource at a specified URI. It instructs OPTIONS The OPTIONS method is used to request information about the communication options available
the server to delete the resource, if possible. for a resource. It can be used to determine which HTTP methods and headers are supported by
PATCH The PATCH method is used to apply partial modifications to a resource. It is typically used when a resource.
you want to update only a portion of a resource, rather than replacing the entire resource. CONNECT The CONNECT method is used to establish a network connection to a resource, typically for use
HEAD The HEAD method is similar to GET but only retrieves the headers of the response, not the actual with a proxy server.
data. It is often used to check the headers or verify the existence of a resource without TRACE TRACE: The TRACE method is used to retrieve a diagnostic trace of the current connection,
downloading its content. helping with debugging and troubleshooting.
DIS Scholar year 2023/2024 UMBB 11 DIS Scholar year 2023/2024 UMBB 12
07/10/2023
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Requests Requests
Request headers Request headers
The most crucial request headers include: The most crucial request headers include:
DIS Scholar year 2023/2024 UMBB 13 DIS Scholar year 2023/2024 UMBB 14
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Requests Requests
Using HTTP APIs (Web application programming interfaces (APIs)) Using HTTP APIs (Web application programming interfaces (APIs))
What is an API? HTTP Request Example (GET):
DIS Scholar year 2023/2024 UMBB 15 DIS Scholar year 2023/2024 UMBB 16
07/10/2023
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Requests Responses
Using HTTP APIs (Web application programming interfaces (APIs)) Anatomy of an HTTP response
HTTP Response Example (200 OK): HTTP/ . OK
Content-Type: application/json
HTTP responses typically include:
{
"id": /, a status code (200 OK!, 404 not found! )
"name": “Amin fname",
headers
"email": " Aminfname @example.com"
} a body (HTML, an image, JSON, etc )
In this response:
The status code 200 OK indicates a successful response.
The Content-Type header specifies that the response contains JSON data.
The response body is a JSON object with user information.
DIS Scholar year 2023/2024 UMBB 17 DIS Scholar year 2023/2024 UMBB 18
II- HyperText Transfer Protocol (HTTP) II- HyperText Transfer Protocol (HTTP)
Responses Responses
Response headers Status codes
Every HTTP response has a status code
There are a few kinds of response headers
There are approximately 50 status codes, but in practice, these are the most commonly
encountered ones.
DIS Scholar year 2023/2024 UMBB 19 DIS Scholar year 2023/2024 UMBB 20
07/10/2023