Kristian,
It’s interesting your raise this - I was having trouble just yesterday working out why my colleague kept getting locked out of the server (I have fail2ban installed).
Turns out he was going to http://ourdomain.com/dba/ (with a trailing slash)
It all works if you go to http://ourdomain.com/dba (without a trailing slash)
From my testing it looks like ‘dba’ and ‘dba/‘ both get caught by %rest:path(‘/dba’) which is redirected to ‘dba/databases’.
However this means without the slash the browser interprets this as a redirect to http://ourdomain.com/dba/databases With the slash it is interpreted as a redirect to http://ourdomain.com/dba/dba/databases (which doesn’t exist and so after some attempts he was blocked).
I only tested briefly yesterday but I couldn’t see immediately how to fix this (adding another %rest:path('/dba/') didn’t seem to work. But then I don’t know if the regex support affects that?
Interested to hear others’ experience.
Regards, James
Message: 1 Date: Mon, 01 Jun 2015 18:57:06 +0300 From: Kristian Kankainen kristian@keeleleek.ee To: BaseX basex-talk@mailman.uni-konstanz.de Subject: [basex-talk] Strange path problem (revisited) Message-ID: 556C80D2.1050101@keeleleek.ee Content-Type: text/plain; charset=utf-8; format=flowed
Hello!
I noticed that I get different results if I visit the following two urls: http://myhost.domain/webappname/ http://myhost.domain/webappname
The only difference is the trailing slash. My RESTXQ has a path for '/' but not for ''. My setup is with Tomcat. The difference seems to be the basepath for the webapp. Static files etc are not found. This also applies for the BaseX DBA:
http://myhost.domain/webappname/dba/login resolves correctly http://myhost.domain/webappname/dba/login/ doesn't find it's static files etc.
For my own webapp, it's the other way around --- with the trailing slash everything works fine, without it the static files etc aren't found.
Is it yet another Tomcat problem or can it be reproduced on your setups?
Cheers! Kristian
Hi Kristian, hi James,
Yes, this is a known issue, and there is no easy solution to that. The basic problem is that "path" and "path/" have a different meaning for the browser, but they are currently the same for RESTXQ, which treats these paths the same way.
Adam Retter added an issue for that in the EXQuery issue tracker [1]. We didn't come up with a final solution there, but you are invited to join the discussion.
In newer versions of BaseX, however, there is a special case: If a URL addresses the RESTXQ root path, and if it has no trailing slash, it will be redirected to the same URL with trailing slash.
Best, Christian
[1] https://github.com/exquery/exquery/issues/19
On Tue, Jun 2, 2015 at 1:58 PM, James Ball basex-talk@jamesball.co.uk wrote:
Kristian,
It’s interesting your raise this - I was having trouble just yesterday working out why my colleague kept getting locked out of the server (I have fail2ban installed).
Turns out he was going to http://ourdomain.com/dba/ (with a trailing slash)
It all works if you go to http://ourdomain.com/dba (without a trailing slash)
From my testing it looks like ‘dba’ and ‘dba/‘ both get caught by %rest:path(‘/dba’) which is redirected to ‘dba/databases’.
However this means without the slash the browser interprets this as a redirect to http://ourdomain.com/dba/databases With the slash it is interpreted as a redirect to http://ourdomain.com/dba/dba/databases (which doesn’t exist and so after some attempts he was blocked).
I only tested briefly yesterday but I couldn’t see immediately how to fix this (adding another %rest:path('/dba/') didn’t seem to work. But then I don’t know if the regex support affects that?
Interested to hear others’ experience.
Regards, James
Message: 1 Date: Mon, 01 Jun 2015 18:57:06 +0300 From: Kristian Kankainen kristian@keeleleek.ee To: BaseX basex-talk@mailman.uni-konstanz.de Subject: [basex-talk] Strange path problem (revisited) Message-ID: 556C80D2.1050101@keeleleek.ee Content-Type: text/plain; charset=utf-8; format=flowed
Hello!
I noticed that I get different results if I visit the following two urls: http://myhost.domain/webappname/ http://myhost.domain/webappname
The only difference is the trailing slash. My RESTXQ has a path for '/' but not for ''. My setup is with Tomcat. The difference seems to be the basepath for the webapp. Static files etc are not found. This also applies for the BaseX DBA:
http://myhost.domain/webappname/dba/login resolves correctly http://myhost.domain/webappname/dba/login/ doesn't find it's static files etc.
For my own webapp, it's the other way around --- with the trailing slash everything works fine, without it the static files etc aren't found.
Is it yet another Tomcat problem or can it be reproduced on your setups?
Cheers! Kristian
Hello
I have been thinking if using an explicit <base> tag could solve some obvious problems. I haven't tried it, and I'm guessing it could introduce other problems.
Just a thought.
Best regards Kristian
02.06.2015 18:56, Christian Grün kirjutas:
Hi Kristian, hi James,
Yes, this is a known issue, and there is no easy solution to that. The basic problem is that "path" and "path/" have a different meaning for the browser, but they are currently the same for RESTXQ, which treats these paths the same way.
Adam Retter added an issue for that in the EXQuery issue tracker [1]. We didn't come up with a final solution there, but you are invited to join the discussion.
In newer versions of BaseX, however, there is a special case: If a URL addresses the RESTXQ root path, and if it has no trailing slash, it will be redirected to the same URL with trailing slash.
Best, Christian
[1] https://github.com/exquery/exquery/issues/19
On Tue, Jun 2, 2015 at 1:58 PM, James Ball basex-talk@jamesball.co.uk wrote:
Kristian,
It’s interesting your raise this - I was having trouble just yesterday working out why my colleague kept getting locked out of the server (I have fail2ban installed).
Turns out he was going to http://ourdomain.com/dba/ (with a trailing slash)
It all works if you go to http://ourdomain.com/dba (without a trailing slash)
From my testing it looks like ‘dba’ and ‘dba/‘ both get caught by %rest:path(‘/dba’) which is redirected to ‘dba/databases’.
However this means without the slash the browser interprets this as a redirect to http://ourdomain.com/dba/databases With the slash it is interpreted as a redirect to http://ourdomain.com/dba/dba/databases (which doesn’t exist and so after some attempts he was blocked).
I only tested briefly yesterday but I couldn’t see immediately how to fix this (adding another %rest:path('/dba/') didn’t seem to work. But then I don’t know if the regex support affects that?
Interested to hear others’ experience.
Regards, James
Message: 1 Date: Mon, 01 Jun 2015 18:57:06 +0300 From: Kristian Kankainen kristian@keeleleek.ee To: BaseX basex-talk@mailman.uni-konstanz.de Subject: [basex-talk] Strange path problem (revisited) Message-ID: 556C80D2.1050101@keeleleek.ee Content-Type: text/plain; charset=utf-8; format=flowed
Hello!
I noticed that I get different results if I visit the following two urls: http://myhost.domain/webappname/ http://myhost.domain/webappname
The only difference is the trailing slash. My RESTXQ has a path for '/' but not for ''. My setup is with Tomcat. The difference seems to be the basepath for the webapp. Static files etc are not found. This also applies for the BaseX DBA:
http://myhost.domain/webappname/dba/login resolves correctly http://myhost.domain/webappname/dba/login/ doesn't find it's static files etc.
For my own webapp, it's the other way around --- with the trailing slash everything works fine, without it the static files etc aren't found.
Is it yet another Tomcat problem or can it be reproduced on your setups?
Cheers! Kristian
basex-talk@mailman.uni-konstanz.de