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

1 HTTP

HTTP is the protocol for transmitting hypertext documents across the internet. It uses requests and responses to transfer files like HTML documents between clients and servers. A basic HTTP request includes a domain, resource, method, and optional header. Common request methods are GET, POST, and others. Responses typically include status codes and optional response bodies. URLs identify internet resources and include components like the scheme, domain, port, path, query parameters, and fragment.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

1 HTTP

HTTP is the protocol for transmitting hypertext documents across the internet. It uses requests and responses to transfer files like HTML documents between clients and servers. A basic HTTP request includes a domain, resource, method, and optional header. Common request methods are GET, POST, and others. Responses typically include status codes and optional response bodies. URLs identify internet resources and include components like the scheme, domain, port, path, query parameters, and fragment.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

07/10/2023

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)

Here are a few examples of HTTP URLs:


 Simple HTTP URL: http://www.example.com
Path This part defines the specific location or path to the resource on the server. It is separated from
 HTTP URL with Path: http://www.example.com/products/page.html
the domain by a forward slash ("/").
 HTTP URL with Query Parameters: http://www.example.com/search?query=example
Query It is used to send parameters to the resource, typically in the form of key-value pairs. It is
(optional)  Secure HTTPS URL with Port: https://www.example.com:8443
preceded by a question mark ("?").
 URL with Fragment: http://www.example.com/page.html#section2
Fragment It is used to specify a particular section or anchor within the resource, typically preceded by a
(optional)
hash symbol ("#").

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

HTTP requests typically include: An optional request body is available in

 a domain (likeexamplecat.com) HTTP requests. Generally, HTTP GET

 a resource (like /cat.png) requests do not include a request body,

 a method (Get, Post, or something else) while HTTP POST requests often do

 a header (Extra information for a server) include one

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):

GET /api/users/ / HTTP/ .


Web APIs are designed to represent resources such as HTML pages, access web
Host: api.example.com
Accept: application/json
services, retrieve data from databases, and integrate with third-party services (such as
Authorization: Bearer YOUR_API_KEY
social media platforms or payment gateways). They define a set of endpoints (URLs) In this example:
 The request uses the HTTP method GET.
and the corresponding HTTP methods (GET, POST, PUT, DELETE, etc.) that
 It requests the resource located at /api/users/123 on the api.example.com server.
developers can use to request and exchange data with a remote server or service.  The accept header specifies that the client prefers to receive the response in JSON format.
 The Authorization header includes an API key or token for authentication.

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

II- HyperText Transfer Protocol (HTTP)


Responses
Status codes
There are approximately 50 status codes, but in practice, these are the most commonly
encountered ones.

DIS Scholar year 2023/2024 UMBB 21

You might also like