Skip to content

Commit

Permalink
Fix triple dots for <pre> in Web/HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
teoli2003 committed Aug 13, 2021
1 parent c84293e commit 4623499
Show file tree
Hide file tree
Showing 268 changed files with 2,207 additions and 1,505 deletions.
32 changes: 19 additions & 13 deletions files/en-us/web/http/authentication/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The {{HTTPHeader("WWW-Authenticate")}} and {{HTTPHeader("Proxy-Authenticate")}}

The syntax for these headers is the following:

```html
```
WWW-Authenticate: <type> realm=<realm>
Proxy-Authenticate: <type> realm=<realm>
```
Expand All @@ -65,7 +65,7 @@ Here, `<type>` is the authentication scheme ("Basic" is the most common scheme a

The {{HTTPHeader("Authorization")}} and {{HTTPHeader("Proxy-Authorization")}} request headers contain the credentials to authenticate a user agent with a (proxy) server. Here, the `<type>` is needed again followed by the credentials, which can be encoded or encrypted depending on which authentication scheme is used.

```html
```
Authorization: <type> <credentials>
Proxy-Authorization: <type> <credentials>
```
Expand Down Expand Up @@ -103,30 +103,36 @@ To password-protect a directory on an Apache server, you will need a `.htaccess`

The `.htaccess` file typically looks like this:

AuthType Basic
AuthName "Access to the staging site"
AuthUserFile /path/to/.htpasswd
Require valid-user
```
AuthType Basic
AuthName "Access to the staging site"
AuthUserFile /path/to/.htpasswd
Require valid-user
```

The `.htaccess` file references a `.htpasswd` file in which each line consists of a username and a password separated by a colon (`:`). You cannot see the actual passwords as they are [hashed](https://httpd.apache.org/docs/2.4/misc/password_encryptions.html) (using MD5-based hashing, in this case). Note that you can name your `.htpasswd` file differently if you like, but keep in mind this file shouldn't be accessible to anyone. (Apache is usually configured to prevent access to `.ht*` files).

aladdin:$apr1$ZjTqBB3f$IF9gdYAGlMrs2fuINjHsz.
user2:$apr1$O04r.y2H$/vEkesPhVInBByJUkXitA/
```
aladdin:$apr1$ZjTqBB3f$IF9gdYAGlMrs2fuINjHsz.
user2:$apr1$O04r.y2H$/vEkesPhVInBByJUkXitA/
```

### Restricting access with nginx and basic authentication

For nginx, you will need to specify a location that you are going to protect and the `auth_basic` directive that provides the name to the password-protected area. The `auth_basic_user_file` directive then points to a `.htpasswd` file containing the encrypted user credentials, just like in the Apache example above.

location /status {
auth_basic "Access to the staging site";
auth_basic_user_file /etc/apache2/.htpasswd;
}
```
location /status {
auth_basic "Access to the staging site";
auth_basic_user_file /etc/apache2/.htpasswd;
}
```

### Access using credentials in the URL

Many clients also let you avoid the login prompt by using an encoded URL containing the username and the password like this:

```plain example-bad
```example-bad
https://username:[email protected]/
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ It is possible to add a special HTML {{HTMLElement("link")}} element to a page t

When adding such a tag, you serve the same content for both domains, telling search engines which URL is canonical. In the previous example, `http://www.example.org/whaddup` would serve the same content as `http://example.org/whaddup`, but with an additional {{htmlelement("link")}} element in the head:

`<link href="http://example.org/whaddup" rel="canonical">`
```html
<link href="http://example.org/whaddup" rel="canonical">
``

Unlike the previous case, browser history will consider non-www and www URLs as independent entries.

Expand Down
14 changes: 9 additions & 5 deletions files/en-us/web/http/basics_of_http/data_uris/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ base64 a.txt>b.txt

On Windows, [Convert.ToBase64String](https://docs.microsoft.com/en-us/dotnet/api/system.convert.tobase64string?view=net-5.0) from PowerShell can be used to perform the Base64 encoding:

```html
```bash
[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("hello"))
# outputs to console: aGVsbG8=
```

Alternatively, a GNU/Linux shell (such as [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)) provides the utility `base64`:

```html
```bash
bash$ echo -n hello | base64
# outputs to console: aGVsbG8=
```
Expand All @@ -84,11 +84,15 @@ bash$ echo -n hello | base64

This section describes problems that commonly occur when creating and using `data` URLs.

data:text/html,lots of text...<p><a name%3D"bottom">bottom</a>?arg=val
```
data:text/html,lots of text...<p><a name%3D"bottom">bottom</a>?arg=val
```

This represents an HTML resource whose contents are:

lots of text...<p><a name="bottom">bottom</a>?arg=val
```html
lots of text...<p><a name="bottom">bottom</a>?arg=val
```

- Syntax
- : The format for `data` URLs is very simple, but it's easy to forget to put a comma before the "data" segment, or to incorrectly encode the data into base64 format.
Expand Down Expand Up @@ -119,5 +123,5 @@ This represents an HTML resource whose contents are:
- [Percent encoding](/en-US/docs/Glossary/percent-encoding)
- {{domxref("WindowOrWorkerGlobalScope/atob","atob()")}}
- {{domxref("WindowOrWorkerGlobalScope/btoa","btoa()")}}
- [CSS `url()`](</en-US/docs/Web/CSS/url()>)
- [CSS `url()`](/en-US/docs/Web/CSS/url())
- [URI](/en-US/docs/Glossary/URI)
134 changes: 72 additions & 62 deletions files/en-us/web/http/basics_of_http/evolution_of_http/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ The HTTP protocol used in those early phases was very simple, later dubbed HTTP/

The initial version of HTTP had no version number; it has been later called 0.9 to differentiate it from the later versions. HTTP/0.9 is extremely simple: requests consist of a single line and start with the only possible method {{HTTPMethod("GET")}} followed by the path to the resource (not the URL as both the protocol, server, and port are unnecessary once connected to the server).

GET /mypage.html
```
GET /mypage.html
```

The response is extremely simple too: it only consisted of the file itself.

<HTML>
A very simple HTML page
</HTML>
```html
<html>
A very simple HTML page
</html>
```

Unlike subsequent evolutions, there were no HTTP headers, meaning that only HTML files could be transmitted, but no other type of documents. There were no status or error codes: in case of a problem, a specific HTML file was sent back with the description of the problem contained in it, for human consumption.

Expand All @@ -49,28 +53,32 @@ HTTP/0.9 was very limited and both browsers and servers quickly extended it to b

At this point, a typical request and response looked like this:

GET /mypage.html HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)
```
GET /mypage.html HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)
200 OK
Date: Tue, 15 Nov 1994 08:12:31 GMT
Server: CERN/3.0 libwww/2.17
Content-Type: text/html
<HTML>
A page with an image
<IMG SRC="/myimage.gif">
</HTML>
200 OK
Date: Tue, 15 Nov 1994 08:12:31 GMT
Server: CERN/3.0 libwww/2.17
Content-Type: text/html
<HTML>
A page with an image
<IMG SRC="/myimage.gif">
</HTML>
```

Followed by a second connection and request to fetch the image (followed by a response to that request):

GET /myimage.gif HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)
```
GET /myimage.gif HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)
200 OK
Date: Tue, 15 Nov 1994 08:12:32 GMT
Server: CERN/3.0 libwww/2.17
Content-Type: text/gif
(image content)
200 OK
Date: Tue, 15 Nov 1994 08:12:32 GMT
Server: CERN/3.0 libwww/2.17
Content-Type: text/gif
(image content)
```

These novelties have not been introduced as concerted effort, but as a try-and-see approach over the 1991-1995 period: a server and a browser added one feature and it saw if it got traction. A lot of interoperability problems were common. In November 1996, in order to solve these annoyances, an informational document describing the common practices has been published, {{RFC(1945)}}. This is the definition of HTTP/1.0 and it is notable that, in the narrow sense of the term, it isn't an official standard.

Expand All @@ -89,47 +97,49 @@ HTTP/1.1 clarified ambiguities and introduced numerous improvements:

A typical flow of requests, all through one single connection is now looking like this:

GET /en-US/docs/Glossary/Simple_header HTTP/1.1
Host: developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://developer.mozilla.org/en-US/docs/Glossary/Simple_header

200 OK
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Wed, 20 Jul 2016 10:55:30 GMT
Etag: "547fa7e369ef56031dd3bff2ace9fc0832eb251a"
Keep-Alive: timeout=5, max=1000
Last-Modified: Tue, 19 Jul 2016 00:59:33 GMT
Server: Apache
Transfer-Encoding: chunked
Vary: Cookie, Accept-Encoding

(content)

GET /static/img/header-background.png HTTP/1.1
Host: developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://developer.mozilla.org/en-US/docs/Glossary/Simple_header

200 OK
Age: 9578461
Cache-Control: public, max-age=315360000
Connection: keep-alive
Content-Length: 3077
Content-Type: image/png
Date: Thu, 31 Mar 2016 13:34:46 GMT
Last-Modified: Wed, 21 Oct 2015 18:27:50 GMT
Server: Apache

(image content of 3077 bytes)
```
GET /en-US/docs/Glossary/Simple_header HTTP/1.1
Host: developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://developer.mozilla.org/en-US/docs/Glossary/Simple_header
200 OK
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Wed, 20 Jul 2016 10:55:30 GMT
Etag: "547fa7e369ef56031dd3bff2ace9fc0832eb251a"
Keep-Alive: timeout=5, max=1000
Last-Modified: Tue, 19 Jul 2016 00:59:33 GMT
Server: Apache
Transfer-Encoding: chunked
Vary: Cookie, Accept-Encoding
(content)
GET /static/img/header-background.png HTTP/1.1
Host: developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://developer.mozilla.org/en-US/docs/Glossary/Simple_header
200 OK
Age: 9578461
Cache-Control: public, max-age=315360000
Connection: keep-alive
Content-Length: 3077
Content-Type: image/png
Date: Thu, 31 Mar 2016 13:34:46 GMT
Last-Modified: Wed, 21 Oct 2015 18:27:50 GMT
Server: Apache
(image content of 3077 bytes)
```

HTTP/1.1 was first published as {{rfc(2068)}} in January 1997.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,28 @@ The target of an HTTP request is called a "resource", whose nature isn't defined

The most common form of URI is the Uniform Resource Locator ({{Glossary("URL")}}), which is known as the _web address_.

https://developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Learn/
https://developer.mozilla.org/en-US/search?q=URL
```
https://developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Learn/
https://developer.mozilla.org/en-US/search?q=URL
```

Any of those URLs can be typed into your browser's address bar to tell it to load the associated page (resource).

A URL is composed of different parts, some mandatory and others are optional. A more complex example might look like this:

http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument
```
http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument
```

### URNs

A Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace.
A Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace.

urn:isbn:9780141036144
urn:ietf:rfc:7230
```
urn:isbn:9780141036144
urn:ietf:rfc:7230
```

The two URNs correspond to

Expand Down Expand Up @@ -102,12 +108,14 @@ FTP is still acceptable at the top level (such as typed directly into the browse

## 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
mailto:[email protected]
```
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
mailto:[email protected]
```

## Specifications

Expand Down
Loading

0 comments on commit 4623499

Please sign in to comment.