Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define /http-path #164

Merged
merged 7 commits into from
Jun 5, 2024
Merged

Define /http-path #164

merged 7 commits into from
Jun 5, 2024

Conversation

MarcoPolo
Copy link
Contributor

@MarcoPolo MarcoPolo commented Aug 24, 2023

Summary

Adds a new multiaddr component for /http-path, and define it.

I think this follows RFC 3986's notion of "Path" (section 3.3). Please correct me if I'm wrong.

I'm using http-path instead of httpath (used by IPNI) previously for two reasons:

  1. I prefer joining two full words.
  2. In case there's any conflicting interpretation, this will be unambiguous as it has a different name.

Before Merge

@Winterhuman
Copy link

Winterhuman commented Aug 25, 2023

Out of curiosity, knowing I've probably missed something in the doc which explicitly states this which I didn't understand among the RFC links, are the paths strictly ASCII characters (with punycode needed for UTF-8 conversion), or is encoding the paths as UTF-8 allowed?

@MarcoPolo
Copy link
Contributor Author

Good question. Section 2 of RFC 3986 covers this. Basically it depends on the context. If the context/protocol is UTF-8, then this is UTF-8. In practice I think the string encoding of this will be UTF-8.

@MarcoPolo
Copy link
Contributor Author

I think as is, my document is ambiguous. Only the following characters are not percent-encoded: unreserved / pct-encoded / sub-delims / ":" / "@".

I was trying to avoid the ABNF notation from the RFC, but I might have to include it.

MarcoPolo and others added 2 commits August 25, 2023 10:37
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@achingbrain
Copy link
Member

achingbrain commented Mar 27, 2024

It's an aesthetic point but /httppath is quite hard to read.

I wonder if it could be /http-path (like /p2p-circuit or /webrtc-direct) or even /http+path, since it doesn't really work without /http and makes that section of the multiaddr more specific?

It also opens the door for other modifiers that might be required to create a valid request touched on in #63, such as /http+host/example.com, /http+header/foo=bar, /http+auth/user:password, /http+cookie/foo=bar etc.

@MarcoPolo
Copy link
Contributor Author

/http-path works for me. 👍

@achingbrain
Copy link
Member

Is a multiaddr with /http-path valid without /http also being present?

If not the spec should say so. If so, it should say how to infer a /http tuple when it's not present.

@MarcoPolo
Copy link
Contributor Author

Is a multiaddr with /http-path valid without /http also being present?

Yes. There's an example in the spec with just a /p2p component.

/http refers to the other end supporting an HTTP transport. The /http component is defined at https://github.com/libp2p/specs/blob/master/http/transport-component.md.

@MarcoPolo MarcoPolo changed the title Define /httppath Define /http-path Apr 15, 2024
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

One thing that occurs is that implementations tend to omit the Peer ID from Multiaddrs that are part of PeerInfo objects.

This new segment must be after the Peer ID so these implementations would have to start including the Peer ID which would increase the size of signed peer records, the amount of data transferred during network queries, etc.

@MarcoPolo
Copy link
Contributor Author

I don't expect this component to be present in multiaddrs that a peer shares for connectivity as in Peer Routing Records. Only in cases where you want to reference a specific HTTP resource.

I think DNS records are a good analogy. For example, An A query gives you only ipv4 address to a domain name. It just gives you the thing you need to find the server but doesn't give you anything else. Our routing records should be similar. Just the information to reach a server and its peer id.

@MarcoPolo MarcoPolo merged commit cab92e8 into master Jun 5, 2024
1 check passed
@MarcoPolo MarcoPolo deleted the marco/httppath branch June 5, 2024 16:22
achingbrain pushed a commit to multiformats/js-multiaddr that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants