-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
[BUG] response:redirect-to#1
adds scheme and host to URL
#4249
Comments
related eXist-db/public-repo#76 |
Using eXist 6.1.0-SNAPSHOT 94857f2 20220211055142, I can confirm that the xqsuite demonstrates the issue. |
Add new function `app:redirect-to#1 to replace response:redirect-to#1 until eXist-db/exist#4249 is fixed.
I expect the actual code to be present in a different |
@dizzzz Could you clarify? |
@line-o Ah, I see! Were you able to find it? If not, it appears to be the one result here: https://github.com/eXist-db/exist/search?q=redirect-to. |
@joewiz No that just calls the |
According to the Javadoc of HTTPServletResponse.sendRedirect the behaviour we are observing should not be happening. That looks to me as if the ResponseWrapper implementation that is used here would interfere. |
So digging deeper it appears to be a jetty specific behaviour. The host header is used to build absolute URLs including scheme and host. |
I can confirm that adding <Set name="relativeRedirectAllowed">
<Property name="jetty.httpConfig.relativeRedirectAllowed" default="true"/>
</Set> to jetty.xml (for me it was at Line 78) does indeed change the behaviour so that the above tests will pass. |
Thanks for confirming, as I mentioned on the call I was almost certain that this was not an eXist-db issue with redirect-to. Glad to have that confirmed! Reading the Jetty issue that you linked, it states that:
and that the Jetty project have recently added an option to support this newer behavioural option. I don't think we should change the default Jetty config in eXist-db at this time, as this has:
I think the fact that we already expose Jetty options that allow you to solve your problem is enough for the moment. @line-o Out of interest... What is the HTTP Client that you are using where you are seeing some sort of error due to this? It would seem sensible for you to issue a bug-report to them, as they should very likely support what has been the "de-facto" approach in at least Apache HTTP and Jetty for a long time already. |
Someone seems to have deleted my earlier comments from directly after the community-call about this being part of the Java Servlet Spec, and therefore implemented by Jetty :-( |
I was wondering where the earlier comment went. But de-facto, just by looking at MDN there is zero need to add scheme and URL to the location header. |
"My" HTTP-client being all major browsers. |
That depends on which RFCs you are supporting. The MDN page you referenced does not explain which version of the RFCs they are discussing. In addition that page does say that the
As far as I can see, eXist-db's (i.e. Jetty's) behaviour works with "all major browsers" - I quickly tested fairly recent Chrome, Firefox, Safari and IE browsers. @line-o Can you tell us, what is the actual error that you are experiencing? For reference, with Google Chrome as the client, the TCP dump trace from Wireshark looks like:
|
@adamretter Are these the comments you mentioned as having been deleted? #4264 (comment). |
@joewiz Ahaha - so not deleted - just added to the wrong issue! Thanks :-) |
There are three forms of absolute URLs
When redirecting to a resource there is no need to include the host, if the resource is known to be on the same one as the initial request went to. In the case of the linked issue this means that either 1 or 3 would have been fine. Jetty, however uses the host header of the initial request and adds that to the location header of the response together with the scheme it was called with. This raises a series of issues:
All of the above is fixed by "allowing" jetty to have absolute URLs in the location header that start with a slash while redirecting other hosts using fully-qualified URLs (2,3) will still continue to work. |
Are these actually real-world issues? - As we know that Apache HTTPD Server does the same as Jetty, and Apache HTTPD is likely the most widely deployed web-server in the world!
I actually have that working on plenty of servers for many years now where my reverse-proxy is nginx. I would still like to know what the actual error is that you have seen... |
Describe the bug
Calling
response:redirect-to(xs:anyURI("/exist/apps/monex/index.html"))
to issue a redirect with status code 302 will add the scheme and host to the URL.Expected behavior
The temporary redirect location header to be an absolute or relative URL (see also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location).
To Reproduce
Context (please always complete the following information):
Additional context
eXist-6.0.0
conf.xml
? noneThe text was updated successfully, but these errors were encountered: