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

Support Relative URLs not anchored at the root #4245

Open
bblfish opened this issue Mar 28, 2023 · 3 comments
Open

Support Relative URLs not anchored at the root #4245

bblfish opened this issue Mar 28, 2023 · 3 comments
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted nice-to-have (low-prio) Tasks which make sense, however are not very high priority, feel free to help out!

Comments

@bblfish
Copy link

bblfish commented Mar 28, 2023

In RFC5988 and it's successor RFC8288: Web Linking the BNF of the Link header is defined as

link-value = "<" URI-Reference ">" *( OWS ";" OWS link-param )

where URI-Reference can be a relative url as defined in rfc3986.

I am using the actor hierarchy to map a collection hierarchy so that I should for example be able to compare to actor URIs and build up a relative path such as
<../../.acl> without needing to know what the full url of the server is, nor what the root url is. That is userful as the server need not serve urls from the root.

The problem with the current Link header is that it takes a sequences of akka.http.scaladsl.model.headers.LinkValue objects, where case class LinkValue(uri: Uri, params: immutable.Seq[LinkParam]) is constructed using Uri which does not support urls containing ../ path segments.

@bblfish
Copy link
Author

bblfish commented Mar 28, 2023

A workaround is to use RawHeader in this case.

RawHeader("Link","<../.acl>; rel=\"https://www.w3.org/ns/auth/acl#accessControl\"")

But given the close mapping between URLs and akka paths really a future version should perhaps take relative urls more seriously.

But that makes me wonder what happens if an Akka http client parses such a Link header... It should relativise the URLs to the base, but akka Uri does not have a method to do that.

@johanandren
Copy link
Member

I think this is the first time we have seen any requests to support such root-relative link headers (the only thing related I can find is a previous issue by you #99 ). Not anything we will prioritize but we'd be open to looking at PRs allowing such. Gut feeling is that it seems tricky to do in a binary compatible way.

@johanandren johanandren added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted nice-to-have (low-prio) Tasks which make sense, however are not very high priority, feel free to help out! labels Apr 18, 2023
@bblfish
Copy link
Author

bblfish commented May 4, 2023

Speaking of the Link relation it seems to me that there it is a bit wasteful in cpu to calculate if the LinkValue relation contains the characters " ,;" before quoting one could always quote, especially when given a Uri. I think a better model for LinkParam in Scala3 would be LinkParam(key: String|Ur)I, then for Uri one could automatically add the quotes.

This has led me to discover a bug in http4s which assumed the quoting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted nice-to-have (low-prio) Tasks which make sense, however are not very high priority, feel free to help out!
Projects
None yet
Development

No branches or pull requests

2 participants