Traducción en curso
El objetivo de una petición HTTP es llamada "recurso", de manera natural no se encuentre definido; puede ser un documento, una foto, o cualquier otro. Cada recurso es identificado por un Identificador Uniforme de Recursos(URI) utilizado a través de HTTP para la identificación de recursos.
La identidad y la localización del recurso en la Web son en su mayoria a través de una sola dirección URL (Identificación Uniforme de Recursos, un tipo de URI). A veces hay razones de identidad y localización no se realizan por el mismo URI: HTTP usa un encabezado HTTP especifico, Alt-Svc
cuando el recurso solicitado por el cliente quiere acceder a él en otro lugar.
URLs and URNs
URLs
La forma más común de URI es el Localizador Uniforme de Recursos (URL), que se conoce como la dirección web.
https://developer.mozilla.org https://developer.mozilla.org/en-US/docs/Learn/ https://developer.mozilla.org/en-US/search?q=URL
Cualquiera de estas URLS se pueden escribir en la barra de direcciones de su navegador para decirle que cargue la pagina asociada (recurso).
Una URL esta compuesta de diferentes partes, algunas obligatorias y otras son opcionales. Un ejemplo más complejo podría tener este aspecto:
https://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument
URNs
Un URN es un URI que identifica un recurso por su nombre en un espacio de nombres particular.
urn:isbn:9780141036144 urn:ietf:rfc:7230
Las dos URNs corresponden a
- El libro Novecientas ochenta y ocho por George Orwell,
- La especificación IETF 7230, Hypertext Transfer Protocol (HTTP/1.1): Sintaxis de Mensajes y Enrutamiento.
Syntax of Uniform Resource Identifiers (URIs)
Scheme or protocol
https://
is the protocol. It indicates which protocol the browser must use. Usually it is the HTTP protocol or its secured version, HTTPS. The Web requires one of these two, but browsers also know how to handle other protocols such asmailto:
(to open a mail client) orftp:
to handle file transfer, so don't be surprised if you see such protocols. Common schemes are:
Scheme | Description |
---|---|
data | Data URIs |
file | Host-specific file names |
ftp | File Transfer Protocol |
http/https | Hyper text transfer protocol (Secure) |
mailto | Electronic mail address |
ssh | Secure shell |
tel | telephone |
urn | Uniform Resource Names |
view-source | Source code of the resource |
ws/wss | (Encrypted) WebSocket connections |
Authority
www.example.com
is the domain name or authority that governs the namespace. It indicates which Web server is being requested. Alternatively, it is possible to directly use an IP address, but because it is less convenient, it is not often used on the Web.
Port
:80
is the port in this instance. It indicates the technical "gate" used to access the resources on the web server. It is usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP and 443 for HTTPS) to grant access to its resources. Otherwise it is mandatory.
Path
/path/to/myfile.html
is the path to the resource on the Web server. In the early days of the Web, a path like this represented a physical file location on the Web server. Nowadays, it is mostly an abstraction handled by Web servers without any physical reality.
Query
?key1=value1&key2=value2
are extra parameters provided to the Web server. Those parameters are a list of key/value pairs separated with the&
symbol. The Web server can use those parameters to do extra stuff before returning the resource to the user. Each Web server has its own rules regarding parameters, and the only reliable way to know how a specific Web server is handling parameters is by asking the Web server owner.
Fragment
#SomewhereInTheDocument
is an anchor to another part of the resource itself. An anchor represents a sort of "bookmark" inside the resource, giving the browser the directions to show the content located at that "bookmarked" spot. On an HTML document, for example, the browser will scroll to the point where the anchor is defined; on a video or audio document, the browser will try to go to the time the anchor represents. It is worth noting that the part after the #, also known as fragment identifier, is never sent to the server with the request.
Examples
https://developer.mozilla.org/en-US/docs/Learn tel:+1-816-555-1212 [email protected]:mdn/browser-compat-data.git ftp://example.org/resource.txt urn:isbn:9780141036144
Specifications
Specification | Title |
---|---|
RFC 7230, section 2.7: Uniform Resource Identifiers | Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing |