Skip to content

Commit 9d3dd76

Browse files
committed
Rephrase and use examples
1 parent 7756753 commit 9d3dd76

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

protocols/httppath.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
# `httppath`
22

33
This protocol encodes an HTTP Path to a resource. In the string representation,
4-
characters in the reserved set are percent-encoded ( "/" becomes "%2F").
5-
Percent-encoding itself is defined by [RFC 3986 Section
6-
2.1](https://datatracker.ietf.org/doc/html/rfc3986#section-2.1). In the binary representation, no escaping is needed as the value is length prefixed.
7-
8-
To ease implementation and benefit from reusing existing percent-encoding logic
9-
present in many environments (Go's
10-
[url.PathEscape](https://pkg.go.dev/net/[email protected]#PathEscape); JS's
11-
[encodeURIComponent](http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent);
12-
and Rust's [many
13-
crates](https://crates.io/search?q=percent%20encode&sort=downloads)), it is
14-
acceptable to encode more characters than the reserved set. While it's not
15-
necessary to encode a space " " as %20, it's is acceptable to do so.
4+
the path is encoded in a way consistent with a single URI Path segment per [RFC 3986 Section
5+
3.3](https://datatracker.ietf.org/doc/html/rfc3986#autoid-23). Specifically
6+
following the grammar of a single `segment-nz`. In the binary
7+
representation, no encoding is needed as the value is length prefixed.
168

179
When comparing multiaddrs, implementations should compare their binary
1810
representation to avoid ambiguities over which characters were escaped.
1911

20-
## Reserved Characters
12+
## Examples
2113

22-
| Character | Reason |
23-
| --------- | ---------------------------------------------------------------------------------------------------- |
24-
| `/` | Multiaddr component separator |
25-
| `%` | Percent encoding indicator |
26-
| `?` | Marks the end of an HTTP path |
27-
| `#` | Reserved gen-delim character by [rfc3986](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2) |
28-
| `[` | Reserved gen-delim character by [rfc3986](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2) |
29-
| `]` | Reserved gen-delim character by [rfc3986](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2) |
14+
The following is a table of examples converting some common HTTP paths to their Multiaddr string form.
15+
16+
| HTTP Path | Multiaddr string form |
17+
| --------------- | -------------------------------- |
18+
| / | n/a. This is implied. |
19+
| /user | `/httppath/user` |
20+
| /api/v0/login | `/httppath/api%2Fv0%2Flogin` |
21+
| /tmp/foo/../bar | `/httppath/tmp%2Ffoo%2F..%2Fbar` |
22+
| a%20space | `/httppath/a%2520space` |
23+
| a%2Fslash | `/httppath/a%252Fslash` |
3024

3125
## Usage
3226

0 commit comments

Comments
 (0)