Skip to content

Allow default port in clients #1048

@skunert

Description

@skunert

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions