-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix the absuri
function to correctly handle relative location paths
#13
Conversation
Thanks this seems useful. It'll need some documentation and tests, please :-) In particular https://tools.ietf.org/html/rfc7230#section-5.5 should be referenced somewhere here. About the API — I think the constructor is not the best place to do this as it's not generic URI functionality. It seems to be an HTTP-specific concept. Looking at the way you use this in https://github.com/JuliaWeb/HTTP.jl/pull/630/files, is the problem here that |
Ah, yes this might actually be the situation. |
Unfortunately the design rationale for some of these things was lost as Sam's not around and I think he wrote most of this. But it seems |
effective_request_uri
kwarg to the URI
and absuri
functionsabsuri
function to correctly handle relative location paths
You can ignore the |
Alright, take a look now. I've removed the HTTP tests and I've added some unit tests. I've also added references to the appropriate documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I have a couple more queries about some detail. Especially what to do about the fragment? (Is this relevant for the Location
header?)
("https://en.wikipedia.org/api/rest_v1/page/summary/Potatoes", "Potato", "https://en.wikipedia.org/api/rest_v1/page/summary/Potato"), | ||
("https://en.wikipedia.org/api/rest_v1/page/summary/Potatoes", "./Potato", "https://en.wikipedia.org/api/rest_v1/page/summary/Potato"), | ||
("https://en.wikipedia.org/api/rest_v1/page/summary/Potatoes", "/foo/bar/baz", "https://en.wikipedia.org/foo/bar/baz"), | ||
("https://en.wikipedia.org/api/rest_v1/page/summary/Potatoes", "https://julialang.org/foo/bar/baz", "https://julialang.org/foo/bar/baz"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Let's add a test for query
handling` as well?
path = String(uristring(normpath(joinpath(URI(; path = context.path), "..", String(uri.path))))) | ||
end | ||
|
||
return URI(context; path=path, query=uri.query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's meant to happen to fragment
here?
# 2. https://web.archive.org/web/20200926022629/https://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-17.html | ||
# 3. https://www.rfc-editor.org/rfc/rfc3986.html#section-4.2 | ||
# 4. https://web.archive.org/web/20201106144353/https://www.rfc-editor.org/rfc/rfc3986.html#section-4.2 | ||
# 5. https://www.rfc-editor.org/rfc/rfc3986.html#section-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the official reference https://tools.ietf.org/html/rfc3986?
I've been doing some local testing with this branch (since I needed the feature), and I believe I found a bug. Adding a relative URI to an absolute one seems to give an invalid URI. Namely:
The |
Unfortunately, I don't have the time right now to fix the bugs and finish up this pull request. Perhaps someone else would be willing to pick up the reins? Please feel free to take this code and use it as a starting point! |
This pull request fixes the
absuri
function to correctly handle relative location paths.Fixes JuliaWeb/HTTP.jl#435
Fixes JuliaWeb/HTTP.jl#626