-
Notifications
You must be signed in to change notification settings - Fork 206
Description
Currently users have to pass a impl AsRef<str> to the client builder that includes a port.
I know there have been other issues (#554, paritytech/subxt#644) about this, and it is marked as blocked on hyperium/http#509. But I would still like to advocate once more for jsonrpsee handling of a default port when passing a URL to it.
As a library user, I expect that I could pass a valid URL to jsonrpsee. The URL standard says that the port should be omitted if it is the default port. This is also what users expect.
The problem is further amplified by rust url and http crates. If an application takes user input and parses it to an url::Url, the default port gets lost, and there is no nice way to force the crate to add it back when converting to string. http::Uri does not remove the default port, but is not able to provide the default port for different schemes (Url has at least port_or_known_default) if none was provided. As result, every application that takes a user-provided URL and passes it on to jsonrpsee needs to fiddle with the ports.
Ideas:
- Maybe jsonrpsee could do manual port handling that does not rely on URI: how to distinguish from invalid port vs no port number hyperium/http#509 (e.g. extracting it with a regex).
- Alternatively we could maybe have a builder method
build_with_components(scheme, host, port, path ...)which would add some convenience