You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rainer Jung <ra...@kippdata.de> on 2011/06/29 13:10:26 UTC

response.encodeURL("http://localhost:8080") produces an invalid URL?

Motivated by

https://issues.apache.org/jira/browse/WICKET-3841

I tested response.encodeURL("http://localhost:8080") and I get
http://localhost:8080;jsessionid=... (cookies off).

Note that there is no slash between the port and the sessionid path info.

According to my reading of RFC3986 (URIs), the input URI is a correct
URI, the resulting URI is not: because it has an authority, the rest
must be zero or more path-abempty, which always start with a slash.

Did anyone stumble over this yet? If there's no objections, I'll write a
patch and check, what the TCK has to say.

The spec does not see to contain any specification of encodeURL apart
from the JavaDoc.

Regards,

Rainer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: response.encodeURL("http://localhost:8080") produces an invalid URL?

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/6/29 Erik Bertelsen <be...@gmail.com>:
> 2011/6/29 Konstantin Kolinko <kn...@gmail.com>:
>
>>
>> From HTTP standpoint it should be http://localhost:8080/ and in my
>> experience browsers add the trailing slash automatically. I have not
>> looked whether the actual HTTP spec is more strict regarding such
>> URLs.
>>
>
> Actually my experience is slightly different, i.e. the HTTP servers
> send a redirect which adds the trailing /.

Redirect is sent for  folder -> folder/, but here we are talking about
server root ('/').

For the server root the request itself should contain "/". That is
taken care by the browser: in an HTTP request, e.g.
GET / HTTP/1.0
 - the requested path cannot be empty, because multiple spaces are
treated as single one.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: response.encodeURL("http://localhost:8080") produces an invalid URL?

Posted by Erik Bertelsen <be...@gmail.com>.
2011/6/29 Konstantin Kolinko <kn...@gmail.com>:

>
> From HTTP standpoint it should be http://localhost:8080/ and in my
> experience browsers add the trailing slash automatically. I have not
> looked whether the actual HTTP spec is more strict regarding such
> URLs.
>

Actually my experience is slightly different, i.e. the HTTP servers
send a redirect which adds the trailing /.

In a tomcat context, this actually may make an important difference:
If you connect directly to an HTTP port on a tomcat with an URL like
http://server:8260/app where app is an webapp running in this tomcat's
webapps directory, the browser will be directed to
http://server:8260/app/

If you have a JkMount in an apache httpd server mapping
http://server/app/* to http://tomcat-server:someport/app/* then
suddenly the trailing / is necessary in the initial browser url to
reach the app's front page.

regards
- Erik

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: response.encodeURL("http://localhost:8080") produces an invalid URL?

Posted by Rainer Jung <ra...@kippdata.de>.
On 29.06.2011 13:55, Konstantin Kolinko wrote:
> 2011/6/29 Rainer Jung <ra...@kippdata.de>:
>> Motivated by
>>
>> https://issues.apache.org/jira/browse/WICKET-3841
>>
>> I tested response.encodeURL("http://localhost:8080") and I get
>> http://localhost:8080;jsessionid=... (cookies off).
>>
>> Note that there is no slash between the port and the sessionid path info.
>>
>> According to my reading of RFC3986 (URIs), the input URI is a correct
>> URI, the resulting URI is not: because it has an authority, the rest
>> must be zero or more path-abempty, which always start with a slash.
>>
>> Did anyone stumble over this yet? If there's no objections, I'll write a
>> patch and check, what the TCK has to say.
>>
>> The spec does not see to contain any specification of encodeURL apart
>> from the JavaDoc.
>>
> 
> From RFC3986 alone I agree that
> 1) http://localhost:8080
> looks like a valid URL by RFC3986.
> (like any other URL without a trailing slash, e.g. mailto:)
> 
> From HTTP standpoint it should be http://localhost:8080/ and in my
> experience browsers add the trailing slash automatically. I have not
> looked whether the actual HTTP spec is more strict regarding such
> URLs.
> 
> 2) http://localhost:8080;jsessionid=...
> is an invalid URL.
> 
> I am +1 to use "/" as the path if it is an absolute URL, scheme is
> http or https and the path is empty. (I guess that there is a check
> for the scheme name already?).

If the URI doesn't point to the application itself, encodeURL() doesn't
change the URL. This is especially true, for any non-http(s) scheme.

> So that it becomes
> http://localhost:8080/;jsessionid=...

Implemented in r1142959.

Now the next question is about encodeRedirectURL(). It behaves like
encodeURL() except it doesn't fix empty URLs ("") and does not yet have
the empty path fix. This difference seems to go back long in time (I
checked back until 2003). Should we keep this difference (don't fix if
it ain't broken), or should encodeRedirectURL() behave exactly the same
as encodeURL()?

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: response.encodeURL("http://localhost:8080") produces an invalid URL?

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/6/29 Rainer Jung <ra...@kippdata.de>:
> Motivated by
>
> https://issues.apache.org/jira/browse/WICKET-3841
>
> I tested response.encodeURL("http://localhost:8080") and I get
> http://localhost:8080;jsessionid=... (cookies off).
>
> Note that there is no slash between the port and the sessionid path info.
>
> According to my reading of RFC3986 (URIs), the input URI is a correct
> URI, the resulting URI is not: because it has an authority, the rest
> must be zero or more path-abempty, which always start with a slash.
>
> Did anyone stumble over this yet? If there's no objections, I'll write a
> patch and check, what the TCK has to say.
>
> The spec does not see to contain any specification of encodeURL apart
> from the JavaDoc.
>

>From RFC3986 alone I agree that
1) http://localhost:8080
looks like a valid URL by RFC3986.
(like any other URL without a trailing slash, e.g. mailto:)

>From HTTP standpoint it should be http://localhost:8080/ and in my
experience browsers add the trailing slash automatically. I have not
looked whether the actual HTTP spec is more strict regarding such
URLs.

2) http://localhost:8080;jsessionid=...
is an invalid URL.

I am +1 to use "/" as the path if it is an absolute URL, scheme is
http or https and the path is empty. (I guess that there is a check
for the scheme name already?).

So that it becomes
http://localhost:8080/;jsessionid=...

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org