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

Explore a function to calculate the URL "service" #875

Open
alandefreitas opened this issue Oct 30, 2024 · 0 comments
Open

Explore a function to calculate the URL "service" #875

alandefreitas opened this issue Oct 30, 2024 · 0 comments
Labels

Comments

@alandefreitas
Copy link
Member

This is often calculated as something like:

auto service = url.has_port() ? url.port() : url.scheme();

The term is described in rfc6335 and mentioned in rfc8615 and rfc7595.

In Asio, the async_resolve function returns endpoints that can be directly used for connect operations. The description of the service parameter is:

service
A string identifying the requested service. This may be a descriptive name or a numeric string corresponding to a port number. It may be an empty string, in which case all resolved endpoints will have a port number of 0.

There's no concept of ports in a DNS registry, so there is a good chance it is there for users' convenience. Otherwise, users would need to transform the results one more time. It probably uses an OS service to identify the service. It might complete with an error if the service is unknown.

auto service = url.has_port() ? url.port() : url.scheme(); might be good enough for an application with an expectation about what would already be in the URL. But a solution in Boost.URL would be more sophisticated than that:

  • It's independent from the internals of url_view_base. So, it could/should be a free function.
  • I still have to evaluate how useful that is because the ASIO resolver can use the OS to resolve the default port for more services.
  • When there's no scheme or port, we might need to return a system::result<...> so we can account for schemes we don't know about.
  • Our scheme enum is very limited, and we don't have access to an OS service for that. We could consider an official list of schemes here as in rfc7595.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant