--- type: practical --- The web $\neq$ The internet ![As portrayed in CN](Pasted%20image%2020241121115442.png) As portrayed in CN ## URIs A **URI (Uniform Resource Identifier)** identifies a resource, either by its name or location, and includes both URLs and URNs. A **URL (Uniform Resource Locator)** is a type of URI that specifies the exact location of a resource on the web, including its access method (e.g., HTTP, FTP). Bad naming... * URLs and URNs are **URI Schemes** * URLs - `transport://user:password@host:port/path[?search][#fragmentid]` * URNs - Is a logical address of a resource ## HTTP - Port 80 usually - TCP ### MIME **MIME (Multipurpose Internet Mail Extensions)** is a standard that extends email and web protocols to support text in character sets other than ASCII, as well as attachments like images, audio, video, and other file types. **HTTP does not have these built-in!** - No state retained between request/response pairs - Connections **can** persist ![Server_client](server_client.canvas) | Term | Explanation | | ------------- | ----------------------------------------------- | | Origin Server | Server where resources reside | | Proxy | Program that can act on behalf of origin server | | Gateway | Intermediary for some other server | | Tunnel | Relay between two connections (blindly) | --- ### Content negotiation - Content can be available in multiple variants - Representation is to be served based on the **content negotiation mechanism** | Type of content negotiation | Description | | --------------------------- | -------------------------------------------------------------------- | | Server-driven | Client includes headers and server tries to find stuff based on them | | Client-driven | Server responds with a list of available types and client picks | --- ### Messages & methods Cool diagram expressing how protocols are being nested: ![](Pasted%20image%2020241121120647.png) #### Request message (BNF) ```js HTTP-message = request-line | status-line message-header* CRLF message-body? message-header = general-header | entity-header | request-header | response-header (general | entity | request | response)-header = field-name ":" field-content CRLF ``` #### **General Headers** - `Cache-Control`: Caching directives. - `Connection`: Manage persistent connections. - `Transfer-Encoding`: Encoding (e.g., `chunked`, `gzip`). - `Via`: Tracks intermediaries and routing. #### **Entity Headers** - `Content-Encoding`: Compression (e.g., `gzip`). - `Content-MD5`: Body integrity check. - `Expires`: Response expiry date. - `Last-Modified`: Last entity update timestamp. ### Request methods - GET, DELETE, POST, PUT, etc. - They NEED to be used accordingly, although you are not forced to do it at all - Idempotent[^1] requests are side-effects free ![](Pasted%20image%2020241121121317.png) [^1]: Describing an action which, when performed multiple times, has no further effect on its subject after the first time it is performed.