Skip to content

Commit cab92e8

Browse files
authored
Merge pull request #164 from multiformats/marco/httppath
Define `/http-path`
2 parents 5a17910 + 4eee81a commit cab92e8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

protocols.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ code, size, name, comment
2828
465, 0, webtransport,
2929
466, V, certhash,
3030
480, 0, http, HyperText Transfer Protocol
31+
481, V, http-path, Percent-encoded path to an HTTP resource
3132
443, 0, https, Deprecated alias for /tls/http
3233
477, 0, ws, WebSockets
3334
478, 0, wss, Deprecated alias for /tls/ws

protocols/http-path.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# `http-path`
2+
3+
This protocol encodes an HTTP Path to a resource. In the string representation,
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.
8+
9+
When comparing multiaddrs, implementations should compare their binary
10+
representation to avoid ambiguities over which characters were escaped.
11+
12+
## Examples
13+
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 | `/http-path/user` |
20+
| /api/v0/login | `/http-path/api%2Fv0%2Flogin` |
21+
| /tmp/foo/../bar | `/http-path/tmp%2Ffoo%2F..%2Fbar` |
22+
| a%20space | `/http-path/a%2520space` |
23+
| a%2Fslash | `/http-path/a%252Fslash` |
24+
25+
## Usage
26+
27+
`/http-path` should be appended to the end of an existing multiaddr, including after the peer id component (p2p). As an example, here's a multiaddr referencing the `.well-known/libp2p` HTTP resource along with a way to reach that peer:
28+
29+
```
30+
/ip4/1.2.3.4/tcp/443/tls/http/p2p/12D.../http-path/.well-known%2Flibp2p
31+
```
32+
33+
The `/http-path` component can also be appended to just the `/p2p/...` component, and rely on a separate peer discovery mechanism to actually identify the peer's address:
34+
35+
```
36+
/p2p/12D.../http-path/.well-known%2Flibp2p
37+
```

0 commit comments

Comments
 (0)