Wednesday, October 30, 2024

JavaScript Web Concepts, Part2 - URI

What is URI?

Every HTTP request requires URI. A URI (Uniform Resource Identifier) is a string of characters that uniquely identifies a resource on the internet. In the context of HTTP requests, the URI tells the server which resource the client wants to access or interact with. Here’s a breakdown of what a URI is and how it works:

Structure of a URI: 

A URI often contains several components:
  1. Scheme: Specifies the protocol to use, such as http, https, ftp, etc.
  2. Authority: Indicates the domain or IP address of the resource, like www.example.com.
  3. Path: Refers to the specific location of the resource on the server, like /articles/page1.
  4. Query: Includes additional parameters for the request, like ?id=123&name=test.
  5. Fragment: Points to a specific section within the resource, such as #section2.
An example URI:
https://www.example.com/articles/page1?id=123&name=test#section2
In this example:
  • https is the scheme.
  • www.example.com is the authority.
  • /articles/page1 is the path.
  • id=123&name=test is the query.
  • section2 is the fragment.

Types of URIs:

  1. URL (Uniform Resource Locator): A specific type of URI that not only identifies a resource but also provides a way to access it, usually by including the network location (e.g., https://www.example.com).
  2. URN (Uniform Resource Name): Another type of URI that identifies a resource by name within a specific namespace, without necessarily providing a means to locate it (e.g., urn:isbn:0451450523 for a book ISBN).
Use in HTTP Requests: In an HTTP request, the URI tells the server which resource to fetch, update, or delete, depending on the HTTP method used (GET, POST, etc.). For example, in GET /articles/page1?id=123, /articles/page1?id=123 is the URI path and query used to retrieve a specific resource.

URI vs URL: Although often used interchangeably, not every URI is a URL. All URLs are URIs, but not all URIs provide a way to locate a resource directly on the internet.

In short, a URI is a way to identify and locate resources, making it essential for HTTP requests to specify exactly what resource is being accessed on the web.

Meaning of Uniform Resource

"Uniform Resource" refers to a consistent way of identifying resources—whether they are documents, images, services, or any other entities accessible on the internet.

Uniform: The term "uniform" highlights that there is a standardized format for identifying resources, which helps in ensuring compatibility and interoperability across various systems. This uniformity means that all resources, regardless of type, follow the same structure for identification, making it easier to locate and access them in a predictable manner.

Resource: A resource is anything that can be identified on the internet, whether it’s a web page, file, API endpoint, or even an abstract concept like a person’s identity. Resources are often "located" or "accessed" via the internet using a URI (Uniform Resource Identifier).

So, "Uniform Resource" emphasizes the standardized method (or format) for identifying any entity on the internet, allowing for seamless interaction between clients (like browsers) and servers.

What is the standardized method to identify uniform resource?
The standardized method to identify a uniform resource on the internet is through a Uniform Resource Identifier (URI). The URI provides a standardized format for identifying and potentially accessing resources, ensuring consistency across web systems.

A URI has a specific structure defined by standards from organizations like the Internet Engineering Task Force (IETF). The basic structure typically includes:
  1. Scheme: Specifies the protocol or method used to access the resource, like http, https, ftp, etc.
  2. Authority: Defines the domain name or IP address where the resource is hosted, such as www.example.com.
  3. Path: Indicates the specific location of the resource within the server, like /articles/page1.
  4. Query (optional): Allows for additional parameters to specify or filter the resource, such as ?id=123&name=test.
  5. Fragment (optional): Points to a specific section within the resource, like #section2.
Example of a URI
https://www.example.com/articles/page1?id=123&name=test#section2
This standard structure allows any type of resource to be uniformly identified, making it easier for web technologies, clients, and servers to communicate.

No comments:

Post a Comment

Hot Topics