Re: Issue between RewriteValve and DefaultServlet

2017-06-27 Thread Jérémie Barthés

"That behaviour is expected."

I really didn't expect that. it took me two weeks, two years ago to understand 
why i had a redirect and not a forward if my URI last char isn't a '/'
---
"The way to handle this is to wrap the response and intercept
the call that sets the location header and modify the value before
calling the wrapped response."

we have other service using redirection to work. It's tricky to wrap response 
then change location headers without disturbing our 302 redirections.

May this method be protected in following versions ?
"Unlikely at this point."

it would really help in our case. We'll study for other solutions anyway


Thanks

Jeremie


Le 26/06/2017 à 14:52, Mark Thomas a écrit :

On 26/06/17 11:22, Jérémie Barthés wrote:

Thank for your  fast answer

I would like to extend DefaultServlet to override doDirectoryRedirect
but the method is private,
private void doDirectoryRedirect(HttpServletRequest request,
HttpServletResponse response)

May this method be protected in following versions ?

Unlikely at this point.


i can't change a header on the way out, after server started to answer,
can i ?

Correct. The way to handle this is to wrap the response and intercept
the call that sets the location header and modify the value before
calling the wrapped response.

Mark



Regard

Jeremie

PS : i added a custom valve just to put non-rewritten URI in a request
attribute, so i can use it if present when doDirectoryRedirect occurs


Le 26/06/2017 à 12:01, Mark Thomas a écrit :

On 26/06/17 10:55, Jérémie Barthés wrote:

Hi,

I have an issue between org.apache.catalina.valves.rewrite.RewriteValve
and org.apache.catalina.servlets.DefaultServlets

If my request is forwarded by the RewriteValve and then pass into
doDirectoryRedirect in DefaultServlets to be redirected. The hidden
rewritten URI is displayed in the browser.

To test it, try the following example (any tomcat 8, 8.5 or 9)

add RewriteValve in conf/server.xml


add rewriteRule in conf/Catalina/localhost/rewrite.config
RewriteRule ^/iWantThisVisible/(.*) $/examples/$1/

start tomcat

go to following URLs (any internet browser) :
http://localhost:8080/iWantThisVisible/servlets
http://localhost:8080/iWantThisVisible/servlets/

That behaviour is expected.

If you want to stick with the RewriteValve you'll need to write a custom
Valve or Filter to modify the HTTP headers on the way out.

You might be better off writing a custom Servlet that does a forward.

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Issue between RewriteValve and DefaultServlet

2017-06-26 Thread Jérémie Barthés

Thank for your  fast answer

I would like to extend DefaultServlet to override doDirectoryRedirect 
but the method is private,
private void doDirectoryRedirect(HttpServletRequest request, 
HttpServletResponse response)


May this method be protected in following versions ?

i can't change a header on the way out, after server started to answer, 
can i ?


Regard

Jeremie

PS : i added a custom valve just to put non-rewritten URI in a request 
attribute, so i can use it if present when doDirectoryRedirect occurs



Le 26/06/2017 à 12:01, Mark Thomas a écrit :

On 26/06/17 10:55, Jérémie Barthés wrote:

Hi,

I have an issue between org.apache.catalina.valves.rewrite.RewriteValve
and org.apache.catalina.servlets.DefaultServlets

If my request is forwarded by the RewriteValve and then pass into
doDirectoryRedirect in DefaultServlets to be redirected. The hidden
rewritten URI is displayed in the browser.

To test it, try the following example (any tomcat 8, 8.5 or 9)

add RewriteValve in conf/server.xml


add rewriteRule in conf/Catalina/localhost/rewrite.config
RewriteRule ^/iWantThisVisible/(.*) $/examples/$1/

start tomcat

go to following URLs (any internet browser) :
http://localhost:8080/iWantThisVisible/servlets
http://localhost:8080/iWantThisVisible/servlets/

That behaviour is expected.

If you want to stick with the RewriteValve you'll need to write a custom
Valve or Filter to modify the HTTP headers on the way out.

You might be better off writing a custom Servlet that does a forward.

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Issue between RewriteValve and DefaultServlet

2017-06-26 Thread Jérémie Barthés

Hi,

I have an issue between org.apache.catalina.valves.rewrite.RewriteValve
and org.apache.catalina.servlets.DefaultServlets

If my request is forwarded by the RewriteValve and then pass into
doDirectoryRedirect in DefaultServlets to be redirected. The hidden
rewritten URI is displayed in the browser.

To test it, try the following example (any tomcat 8, 8.5 or 9)

add RewriteValve in conf/server.xml


add rewriteRule in conf/Catalina/localhost/rewrite.config
RewriteRule ^/iWantThisVisible/(.*)$/examples/$1/

start tomcat

go to following URLs (any internet browser) :
http://localhost:8080/iWantThisVisible/servlets
http://localhost:8080/iWantThisVisible/servlets/

Regards

Jeremie



Re: RewriteValve forward or redirect ?

2017-06-22 Thread Jérémie Barthés
May you please test RewriteValve with any tomcat after version 8 with 
following conditions :


add RewriteValve in conf/server.xml


add rewriteRule in conf/Catalina/localhost/rewrite.config
RewriteRule ^/IWantThisVisible/(.*)$ /examples/$1/

start tomcat

go to following URL (any internet browser) :
http://localhost:8080/IWantThisVisible/servlets
http://localhost:8080/IWantThisVisible/servlets/

Thanks for you help

Jeremie


Le 20/06/2017 à 18:50, Jérémie Barthés a écrit :

RewriteRule ^/visibleURL/(.*)$ /examples/$1/
(missing space between ^/visibleURL/(.*)$ and /examples/$1/)

Le 20/06/2017 à 18:31, Jérémie Barthés a écrit :

please test what i put in my mail :

install a brand new tomcat 9 from archive (last version)

put a RewriteValve in server.xml



in the file /conf/Catalina/localhost/rewrite.config add
RewriteRule ^/visibleURL/(.*)$/examples/$1/

now start tomcat and go to /visibleURL/servlets/
then go to /visibleURL/servlets

you'll see what i'm talking about

Thanks

Jeremie



Le 20/06/2017 à 18:08, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 6/20/17 9:32 AM, Jérémie Barthés wrote:

http://192.168.1.1:8080/visibleURL/servlets/ URL displayed =
http://192.168.1.1:8080/visibleURL/servlets/ page displayed =
http://192.168.1.1:8080/examples/servlets/

http://192.168.1.1:8080/visibleURL/servlets URL displayed =
http://192.168.1.1:8080/examples/servlets/ page displayed =
http://192.168.1.1:8080/examples/servlets/

i don't want http://192.168.1.1:8080/examples/servlets/ to be
displayed !

What do you mean "URL displayed" and "page displayed"? It sounds like
you want the URL to look exactly as it does look.

- -chris


Le 20/06/2017 à 15:26, Jérémie Barthés a écrit :

Hi,

I have some issues with my brand new tomcat 9.0.0.M21

I just unzipped *windows-64 core*

Then i added the *RewriteValve *in *conf/server.xml* / // //  // //
//
//  /

Then i added a rewriteRule in
*/conf/Catalina/localhost/rewrite.config* file : /RewriteRule
^/visibleURL/(.*)$  /examples/$1/

Then i started tomcat with startup.bat (my IP is 192.168.1.1)

in Firefox, i go to
_*http://192.168.1.1:8080/visibleURL/servlets/ *_ The URL
displayed by firefox
is/**//http://192.168.1.1:8080/visibleURL/servlets// and the
page displayed is /http://192.168.1.1:8080/examples/servlets/ /

now i go to *_http://192.168.1.1:8080/visibleURL/servlet__s_ *The
URL displayed by firefox is
/http://192.168.1.1:8080/examples/servlets//**and the page
displayed is /http://192.168.1.1:8080/examples/servlets/ /* *

I really want my users to see "visibleURL" in the URL displayed
by firefox even if they forget to type a "/". I don't want them
to see "examples" Where did i go wrong ?

Please Help

Thanks a lot

Jeremie




-



To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

For additional commands, e-mail: users-h...@tomcat.apache.org


-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAllJSJQACgkQHPApP6U8
pFhITA/+OeOSADj+aeTCoCZC2q1n8+uzen6pYGNjI22Kk7iZnf529WueXfNaH9U7
6TqF+mfYf5H2gkHQR9Ht+8zDmUzzJsBLK+fKHyBplxU8o1jeC+QmhxC++OgEBVsI
DwEzqHKexGqsqkY2ua37gZm0EVra5HaQbbrPGP2RLqT3JWbx2rMAdEWlsz+mYn81
RBmLWnT3hr4r3xhE799dP/f2IP5uz0akdh68B+4rEnmsMvy3rHfalGt3Jv2yOClr
ompHO+C4ThRdcH8Zn0Y7MOwjvdkAZ1u9DLh84xpz2a33gHJnzz0I+p7cMtbpQVPf
8Z7S+692z4TD2GD0MSedUnNy3ryNvFG8UQZXBJ/pg83ZjmGNHe2orKnqMKgaTGhk
lplXZp1R6wqe2lLdJfyTsK2Lv75/oj+8FbNClfms4blcodmVPKcQq5c23tOx7QBe
RLZpTarNtzWK+3zEgOOSMlkkuuqXvuPNmgkZ7efachk6Lr+gp4nJ9uPbwMrTrVE/
F/ZHhV8nkE2r13fpoi9g2P32VCl9GSqBtJGeOYC4YHHwmmz6SjtT5XbU14XMj28m
lBMyuRmHeP5OsP6yvuaYUa64tMqaUP95/Rhry1Ne7e6R4LRMSqPR7nwKmZxn0kVu
JpCTkf/p9PRmB/S9752JxgwDeKBfcubajRSNI65sXLB5tljhDSE=
=nU9X
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: RewriteValve forward or redirect ?

2017-06-20 Thread Jérémie Barthés

RewriteRule ^/visibleURL/(.*)$ /examples/$1/
(missing space between ^/visibleURL/(.*)$ and /examples/$1/)

Le 20/06/2017 à 18:31, Jérémie Barthés a écrit :

please test what i put in my mail :

install a brand new tomcat 9 from archive (last version)

put a RewriteValve in server.xml



in the file /conf/Catalina/localhost/rewrite.config add
RewriteRule ^/visibleURL/(.*)$/examples/$1/

now start tomcat and go to /visibleURL/servlets/
then go to /visibleURL/servlets

you'll see what i'm talking about

Thanks

Jeremie



Le 20/06/2017 à 18:08, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 6/20/17 9:32 AM, Jérémie Barthés wrote:

http://192.168.1.1:8080/visibleURL/servlets/ URL displayed =
http://192.168.1.1:8080/visibleURL/servlets/ page displayed =
http://192.168.1.1:8080/examples/servlets/

http://192.168.1.1:8080/visibleURL/servlets URL displayed =
http://192.168.1.1:8080/examples/servlets/ page displayed =
http://192.168.1.1:8080/examples/servlets/

i don't want http://192.168.1.1:8080/examples/servlets/ to be
displayed !

What do you mean "URL displayed" and "page displayed"? It sounds like
you want the URL to look exactly as it does look.

- -chris


Le 20/06/2017 à 15:26, Jérémie Barthés a écrit :

Hi,

I have some issues with my brand new tomcat 9.0.0.M21

I just unzipped *windows-64 core*

Then i added the *RewriteValve *in *conf/server.xml* / // //  // //
//
//  /

Then i added a rewriteRule in
*/conf/Catalina/localhost/rewrite.config* file : /RewriteRule
^/visibleURL/(.*)$  /examples/$1/

Then i started tomcat with startup.bat (my IP is 192.168.1.1)

in Firefox, i go to
_*http://192.168.1.1:8080/visibleURL/servlets/ *_ The URL
displayed by firefox
is/**//http://192.168.1.1:8080/visibleURL/servlets// and the
page displayed is /http://192.168.1.1:8080/examples/servlets/ /

now i go to *_http://192.168.1.1:8080/visibleURL/servlet__s_ *The
URL displayed by firefox is
/http://192.168.1.1:8080/examples/servlets//**and the page
displayed is /http://192.168.1.1:8080/examples/servlets/ /* *

I really want my users to see "visibleURL" in the URL displayed
by firefox even if they forget to type a "/". I don't want them
to see "examples" Where did i go wrong ?

Please Help

Thanks a lot

Jeremie




-



To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

For additional commands, e-mail: users-h...@tomcat.apache.org


-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAllJSJQACgkQHPApP6U8
pFhITA/+OeOSADj+aeTCoCZC2q1n8+uzen6pYGNjI22Kk7iZnf529WueXfNaH9U7
6TqF+mfYf5H2gkHQR9Ht+8zDmUzzJsBLK+fKHyBplxU8o1jeC+QmhxC++OgEBVsI
DwEzqHKexGqsqkY2ua37gZm0EVra5HaQbbrPGP2RLqT3JWbx2rMAdEWlsz+mYn81
RBmLWnT3hr4r3xhE799dP/f2IP5uz0akdh68B+4rEnmsMvy3rHfalGt3Jv2yOClr
ompHO+C4ThRdcH8Zn0Y7MOwjvdkAZ1u9DLh84xpz2a33gHJnzz0I+p7cMtbpQVPf
8Z7S+692z4TD2GD0MSedUnNy3ryNvFG8UQZXBJ/pg83ZjmGNHe2orKnqMKgaTGhk
lplXZp1R6wqe2lLdJfyTsK2Lv75/oj+8FbNClfms4blcodmVPKcQq5c23tOx7QBe
RLZpTarNtzWK+3zEgOOSMlkkuuqXvuPNmgkZ7efachk6Lr+gp4nJ9uPbwMrTrVE/
F/ZHhV8nkE2r13fpoi9g2P32VCl9GSqBtJGeOYC4YHHwmmz6SjtT5XbU14XMj28m
lBMyuRmHeP5OsP6yvuaYUa64tMqaUP95/Rhry1Ne7e6R4LRMSqPR7nwKmZxn0kVu
JpCTkf/p9PRmB/S9752JxgwDeKBfcubajRSNI65sXLB5tljhDSE=
=nU9X
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: RewriteValve forward or redirect ?

2017-06-20 Thread Jérémie Barthés

please test what i put in my mail :

install a brand new tomcat 9 from archive (last version)

put a RewriteValve in server.xml



in the file /conf/Catalina/localhost/rewrite.config add
RewriteRule ^/visibleURL/(.*)$/examples/$1/

now start tomcat and go to /visibleURL/servlets/
then go to /visibleURL/servlets

you'll see what i'm talking about

Thanks

Jeremie



Le 20/06/2017 à 18:08, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 6/20/17 9:32 AM, Jérémie Barthés wrote:

http://192.168.1.1:8080/visibleURL/servlets/ URL displayed =
http://192.168.1.1:8080/visibleURL/servlets/ page displayed =
http://192.168.1.1:8080/examples/servlets/

http://192.168.1.1:8080/visibleURL/servlets URL displayed =
http://192.168.1.1:8080/examples/servlets/ page displayed =
http://192.168.1.1:8080/examples/servlets/

i don't want http://192.168.1.1:8080/examples/servlets/ to be
displayed !

What do you mean "URL displayed" and "page displayed"? It sounds like
you want the URL to look exactly as it does look.

- -chris


Le 20/06/2017 à 15:26, Jérémie Barthés a écrit :

Hi,

I have some issues with my brand new tomcat 9.0.0.M21

I just unzipped *windows-64 core*

Then i added the *RewriteValve *in *conf/server.xml* /  // //  // //
//
//  /

Then i added a rewriteRule in
*/conf/Catalina/localhost/rewrite.config* file : /RewriteRule
^/visibleURL/(.*)$  /examples/$1/

Then i started tomcat with startup.bat (my IP is 192.168.1.1)

in Firefox, i go to
_*http://192.168.1.1:8080/visibleURL/servlets/ *_ The URL
displayed by firefox
is/**//http://192.168.1.1:8080/visibleURL/servlets// and the
page displayed is /http://192.168.1.1:8080/examples/servlets/ /

now i go to *_http://192.168.1.1:8080/visibleURL/servlet__s_ *The
URL displayed by firefox is
/http://192.168.1.1:8080/examples/servlets//**and the page
displayed is /http://192.168.1.1:8080/examples/servlets/ /* *

I really want my users to see "visibleURL" in the URL displayed
by firefox even if they forget to type a "/". I don't want them
to see "examples" Where did i go wrong ?

Please Help

Thanks a lot

Jeremie




-



To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

For additional commands, e-mail: users-h...@tomcat.apache.org


-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAllJSJQACgkQHPApP6U8
pFhITA/+OeOSADj+aeTCoCZC2q1n8+uzen6pYGNjI22Kk7iZnf529WueXfNaH9U7
6TqF+mfYf5H2gkHQR9Ht+8zDmUzzJsBLK+fKHyBplxU8o1jeC+QmhxC++OgEBVsI
DwEzqHKexGqsqkY2ua37gZm0EVra5HaQbbrPGP2RLqT3JWbx2rMAdEWlsz+mYn81
RBmLWnT3hr4r3xhE799dP/f2IP5uz0akdh68B+4rEnmsMvy3rHfalGt3Jv2yOClr
ompHO+C4ThRdcH8Zn0Y7MOwjvdkAZ1u9DLh84xpz2a33gHJnzz0I+p7cMtbpQVPf
8Z7S+692z4TD2GD0MSedUnNy3ryNvFG8UQZXBJ/pg83ZjmGNHe2orKnqMKgaTGhk
lplXZp1R6wqe2lLdJfyTsK2Lv75/oj+8FbNClfms4blcodmVPKcQq5c23tOx7QBe
RLZpTarNtzWK+3zEgOOSMlkkuuqXvuPNmgkZ7efachk6Lr+gp4nJ9uPbwMrTrVE/
F/ZHhV8nkE2r13fpoi9g2P32VCl9GSqBtJGeOYC4YHHwmmz6SjtT5XbU14XMj28m
lBMyuRmHeP5OsP6yvuaYUa64tMqaUP95/Rhry1Ne7e6R4LRMSqPR7nwKmZxn0kVu
JpCTkf/p9PRmB/S9752JxgwDeKBfcubajRSNI65sXLB5tljhDSE=
=nU9X
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org





Re: RewriteValve forward or redirect ?

2017-06-20 Thread Jérémie Barthés

http://192.168.1.1:8080/visibleURL/servlets/
URL displayed = http://192.168.1.1:8080/visibleURL/servlets/
page displayed = http://192.168.1.1:8080/examples/servlets/

http://192.168.1.1:8080/visibleURL/servlets
URL displayed = http://192.168.1.1:8080/examples/servlets/
page displayed = http://192.168.1.1:8080/examples/servlets/

i don't want http://192.168.1.1:8080/examples/servlets/ to be displayed !

Le 20/06/2017 à 15:26, Jérémie Barthés a écrit :

Hi,

I have some issues with my brand new tomcat 9.0.0.M21

I just unzipped *windows-64 core*

Then i added the *RewriteValve *in *conf/server.xml*
/  autoDeploy="true">//

//  //
//className="org.apache.catalina.valves.rewrite.RewriteValve"/>//

//  /

Then i added a rewriteRule in 
*/conf/Catalina/localhost/rewrite.config* file :

/RewriteRule ^/visibleURL/(.*)$  /examples/$1/

Then i started tomcat with startup.bat (my IP is 192.168.1.1)

in Firefox, i go to _*http://192.168.1.1:8080/visibleURL/servlets/ *_
The URL displayed by firefox 
is/**//http://192.168.1.1:8080/visibleURL/servlets// and the page 
displayed is /http://192.168.1.1:8080/examples/servlets/ /


now i go to *_http://192.168.1.1:8080/visibleURL/servlet__s_
*The URL displayed by firefox is 
/http://192.168.1.1:8080/examples/servlets//**and the page displayed 
is /http://192.168.1.1:8080/examples/servlets/ /*

*

I really want my users to see "visibleURL" in the URL displayed by 
firefox even if they forget to type a "/". I don't want them to see 
"examples"

Where did i go wrong ?

Please Help

Thanks a lot

Jeremie





-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RewriteValve forward or redirect ?

2017-06-20 Thread Jérémie Barthés

Hi,

I have some issues with my brand new tomcat 9.0.0.M21

I just unzipped *windows-64 core*

Then i added the *RewriteValve *in *conf/server.xml*
/  autoDeploy="true">//

//  //
//className="org.apache.catalina.valves.rewrite.RewriteValve"/>//

//  /

Then i added a rewriteRule in */conf/Catalina/localhost/rewrite.config* 
file :

/RewriteRule ^/visibleURL/(.*)$  /examples/$1/

Then i started tomcat with startup.bat (my IP is 192.168.1.1)

in Firefox, i go to _*http://192.168.1.1:8080/visibleURL/servlets/ *_
The URL displayed by firefox 
is/**//http://192.168.1.1:8080/visibleURL/servlets// and the page 
displayed is /http://192.168.1.1:8080/examples/servlets/ /


now i go to *_http://192.168.1.1:8080/visibleURL/servlet__s_
*The URL displayed by firefox is 
/http://192.168.1.1:8080/examples/servlets//**and the page displayed is 
/http://192.168.1.1:8080/examples/servlets/ /*

*

I really want my users to see "visibleURL" in the URL displayed by 
firefox even if they forget to type a "/". I don't want them to see 
"examples"

Where did i go wrong ?

Please Help

Thanks a lot

Jeremie



Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-23 Thread Jérémie Barthés

Hi,

I send you the patch from 8.0.15
Tell me if it doesn't match with what you expected
Kind regards,

Jérémie


Index: RewriteValve.java
===
--- RewriteValve.java(revision 1661627)
+++ RewriteValve.java(working copy)
@@ -45,6 +45,11 @@
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.valves.ValveBase;
+import org.apache.catalina.valves.rewrite.Resolver;
+import org.apache.catalina.valves.rewrite.ResolverImpl;
+import org.apache.catalina.valves.rewrite.RewriteCond;
+import org.apache.catalina.valves.rewrite.RewriteMap;
+import org.apache.catalina.valves.rewrite.RewriteRule;
 import org.apache.tomcat.util.buf.CharChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.net.URL;
@@ -472,11 +477,31 @@
 chunk.append(host.toString());
request.getCoyoteRequest().serverName().toChars();
 }
+
+boolean folderRedirect = false;
+try{
+request.getMappingData().recycle();
+ 
request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(), 
request.getCoyoteRequest().requestURI(),

+null, request.getMappingData());
+ if(request.getMappingData().redirectPath.toString()!=null){
+folderRedirect = true;
+}
+} catch (Exception e){
+//ignore
+}
+
 request.getMappingData().recycle();
 // Reinvoke the whole request recursively
 try {
request.getConnector().getProtocolHandler().getAdapter().service
 (request.getCoyoteRequest(), 
response.getCoyoteResponse());

+
+if(folderRedirect  
response.getCoyoteResponse().getStatus() == 302){
+ 
if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith(/)){
+String requestParam = 
request.getQueryString() == null ?  : '?' + request.getQueryString();
+response.setHeader(Location, 
request.getCoyoteRequest().requestURI().getByteChunk().toString() + '/' 
+ requestParam);

+}
+}
 } catch (Exception e) {
 // This doesn't actually happen in the 
Catalina adapter implementation

 }



Le 20/02/2015 18:03, Konstantin Kolinko a écrit :

2015-02-20 19:41 GMT+03:00 Christopher Schultz ch...@christopherschultz.net:

Jérémie,

On 2/20/15 4:48 AM, Jérémie Barthés wrote:

instead of just a snippet of fixed code

Sorry Chris,i didn't read this.

How do you want me to provide the patch ?

Presumably, you have a copy of the source code. If you checked-out
from svn, just do this:

/path/to/tomcat-8.0.15 $ svn diff  patch.file

and post the patch file.

If you just downloaded the source in e.g. ZIP, tarball, etc., re-fetch
a pristine copy of the file and then do:

/path/to/tomcat-8.0.15 $ diff path/to/original/RewriteValve.java \
java/org/apache/catalina/valves/rewrite/RewriteValve.java \
 patch.file

The above command shall use diff -u to generate Unified Diff format.

Documentation:
http://tomcat.apache.org/bugreport.html#How_to_submit_patches_and_enhancement_requests

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Index: RewriteValve.java
===
--- RewriteValve.java   (revision 1661627)
+++ RewriteValve.java   (working copy)
@@ -45,6 +45,11 @@
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.valves.ValveBase;
+import org.apache.catalina.valves.rewrite.Resolver;
+import org.apache.catalina.valves.rewrite.ResolverImpl;
+import org.apache.catalina.valves.rewrite.RewriteCond;
+import org.apache.catalina.valves.rewrite.RewriteMap;
+import org.apache.catalina.valves.rewrite.RewriteRule;
 import org.apache.tomcat.util.buf.CharChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.net.URL;
@@ -472,11 +477,31 @@
 chunk.append(host.toString());
 request.getCoyoteRequest().serverName().toChars();
 }
+
+boolean folderRedirect = false;
+try{
+   request.getMappingData().recycle();
+   
request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(),
 request.getCoyoteRequest().requestURI

Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-20 Thread Jérémie Barthés

Le 20/02/2015 11:22, Rémy Maucherat a écrit :

2015-02-20 10:31 GMT+01:00 Jérémie Barthés j.bart...@oodrive.fr:


I send you the patch i did to fix my issue with the RewriteValve (it was
for the 8.0.15),
The goal of that patch is to block the RewriteValve if a 302 automatic
folder '/' redirection occurs. The RewriteValve will rewrite the redirected
URL.


I think the current behavior is 100% correct, so no patch should be
integrated to fix this IMO. The redirection could be useful to avoid
relative paths issues.

Rémy



Weird way to think code. My function ramdomly redirect or forward is 
100% correct behavior troll. I had to spend many days of work to find why
http://localhost:8080/mypath/async = 
http://localhost:8080/examples/jsp/async/

http://localhost:8080/mypath/async/ = http://localhost:8080/mypath/async/
And always think that users will consider first it fails because they 
didn't did configure well rewrite.config or made mistakes in server.xml 
or any else. Not because there's a 100% correct behavior conflict 
between RewriteValve and coyote's Adapter mapper redirection if some of 
your resources are folders.







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-20 Thread Jérémie Barthés
I send you the patch i did to fix my issue with the RewriteValve (it was 
for the 8.0.15),
The goal of that patch is to block the RewriteValve if a 302 automatic 
folder '/' redirection occurs. The RewriteValve will rewrite the 
redirected URL.


first step :
http://localhost:8080/mypath/async = rewritten to 
http://localhost:8080/examples/jsp/async, 302 redirection occurs, 
rollback and redirect to http://localhost:8080/mypath/async/

second step :
now the server receive http://localhost:8080/mypath/async/ = forward to 
http://localhost:8080/examples/jsp/async/

mission complete

The patch may be a little bit dirty since it the first time i add code 
into tomcat and i don't understand all of this.


It starts at the line 481 of the RewriteValve.java

//boolean to know if the rewritten resource is a 
folder and need a redirection

boolean folderRedirect = false;
try{
request.getMappingData().recycle();
request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(), 
request.getCoyoteRequest().requestURI(),

null, request.getMappingData());
if(request.getMappingData().redirectPath.toString()!=null){
folderRedirect = true;
}
} catch (Exception e){
//ignore
}

request.getMappingData().recycle();
// Reinvoke the whole request recursively
try {
request.getConnector().getProtocolHandler().getAdapter().service
(request.getCoyoteRequest(), 
response.getCoyoteResponse());


if(folderRedirect  
response.getCoyoteResponse().getStatus() == 302){

if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith(/)){
String requestParam = 
request.getQueryString() == null ?  : '?' + request.getQueryString();
response.setHeader(Location, 
request.getCoyoteRequest().requestURI().getByteChunk().toString() + '/' 
+ requestParam);

}
}
} catch (Exception e) {
// This doesn't actually happen in the Catalina 
adapter implementation

}


Le 20/02/2015 09:34, Felix Schumacher a écrit :

Am 20.02.2015 08:49, schrieb Rainer Jung:

Am 19.02.2015 um 22:13 schrieb Felix Schumacher:

Am 19.02.2015 um 21:41 schrieb André Warnier:

Jérémie Barthés wrote:
...



Make a file rewrite.config in conf/Catalina/localhost/ that 
contains :

RewriteRule^/mypath/(.*)$/examples/jsp/$1

copy the line
Valve
className=org.apache.catalina.valves.rewrite.RewriteValve /
in the conf/server.xml file, line 131



Since this is a Valve, it will run before Tomcat attempts to match the
URL to an actual directory or webapp.



try the followings URLs :



1) http://localhost:8080/mypath/async

This matches the rewrite rule, so it will be rewritten to URL

  /examples/jsp/async

Then Tomcat will attempt to match this to a directory or webapp, and
find that (catalina_base)/webapps/examples/jsp/async is a directory.
It will thus respond to the browser with a 302 re-direct to

   http://localhost:8080/examples/jsp/async/

which is actually the correct URL.
And this is what will be shown in the browser URL bar. This, in my
view, is expected behaviour.  The server does that, so that when an
actual response is generated (for the correct URL
http://localhost:8080/examples/jsp/async/), the browser can cache this
response under the correct URL.

Then the browser re-issues a request for

   http://localhost:8080/examples/jsp/async/

and that is when Tomcat will actually generate a real response,
because this time it is a correct URL. So the response appears to the
browser, as coming from

   http://localhost:8080/examples/jsp/async/

which is correct.

2) http://localhost:8080/mypath/async/

This also matches the rewrite rule, so it gets rewritten to

http://localhost:8080/examples/jsp/async/

which is a correct URL.
Thus Tomcat will immediately generate a real response (without an
intermediate 302 redirect), which will be appear in the browser URL
bar as a response to

http://localhost:8080/mypath/async/

This is also expected behaviour.

I believe that if you do not want to see the first redirect URL

   http://localhost:8080/examples/jsp/async/

in the browser, you have to modify your rewrite rules, perhaps by
using a RewriteCond with the -d flag, to check first if the URL points
to an existing directory, and if yes add the terminating / yourself
(with a RewriteRule) before other rewrite tests/rules take place.

This rewrite.config


...


will do the trick. I think -d will not work, since /mypath/async is not
existant, it only feels like a directory.


Not clear: the implementation for -d is (case

Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-20 Thread Jérémie Barthés

instead of just a snippet of fixed code

Sorry Chris,i didn't read this.

How do you want me to provide the patch ?

Jérémie

Le 20/02/2015 10:31, Jérémie Barthés a écrit :
I send you the patch i did to fix my issue with the RewriteValve (it 
was for the 8.0.15),
The goal of that patch is to block the RewriteValve if a 302 automatic 
folder '/' redirection occurs. The RewriteValve will rewrite the 
redirected URL.


first step :
http://localhost:8080/mypath/async = rewritten to 
http://localhost:8080/examples/jsp/async, 302 redirection occurs, 
rollback and redirect to http://localhost:8080/mypath/async/

second step :
now the server receive http://localhost:8080/mypath/async/ = forward 
to http://localhost:8080/examples/jsp/async/

mission complete

The patch may be a little bit dirty since it the first time i add code 
into tomcat and i don't understand all of this.


It starts at the line 481 of the RewriteValve.java

//boolean to know if the rewritten resource is a 
folder and need a redirection

boolean folderRedirect = false;
try{
request.getMappingData().recycle();
request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(), 
request.getCoyoteRequest().requestURI(),

null, request.getMappingData());
if(request.getMappingData().redirectPath.toString()!=null){
folderRedirect = true;
}
} catch (Exception e){
//ignore
}

request.getMappingData().recycle();
// Reinvoke the whole request recursively
try {
request.getConnector().getProtocolHandler().getAdapter().service
(request.getCoyoteRequest(), 
response.getCoyoteResponse());


if(folderRedirect  
response.getCoyoteResponse().getStatus() == 302){
if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith(/)){ 

String requestParam = 
request.getQueryString() == null ?  : '?' + request.getQueryString();
response.setHeader(Location, 
request.getCoyoteRequest().requestURI().getByteChunk().toString() + 
'/' + requestParam);

}
}
} catch (Exception e) {
// This doesn't actually happen in the 
Catalina adapter implementation

}


Le 20/02/2015 09:34, Felix Schumacher a écrit :

Am 20.02.2015 08:49, schrieb Rainer Jung:

Am 19.02.2015 um 22:13 schrieb Felix Schumacher:

Am 19.02.2015 um 21:41 schrieb André Warnier:

Jérémie Barthés wrote:
...



Make a file rewrite.config in conf/Catalina/localhost/ that 
contains :

RewriteRule^/mypath/(.*)$/examples/jsp/$1

copy the line
Valve
className=org.apache.catalina.valves.rewrite.RewriteValve /
in the conf/server.xml file, line 131



Since this is a Valve, it will run before Tomcat attempts to match 
the

URL to an actual directory or webapp.



try the followings URLs :



1) http://localhost:8080/mypath/async

This matches the rewrite rule, so it will be rewritten to URL

  /examples/jsp/async

Then Tomcat will attempt to match this to a directory or webapp, and
find that (catalina_base)/webapps/examples/jsp/async is a directory.
It will thus respond to the browser with a 302 re-direct to

   http://localhost:8080/examples/jsp/async/

which is actually the correct URL.
And this is what will be shown in the browser URL bar. This, in my
view, is expected behaviour.  The server does that, so that when an
actual response is generated (for the correct URL
http://localhost:8080/examples/jsp/async/), the browser can cache 
this

response under the correct URL.

Then the browser re-issues a request for

   http://localhost:8080/examples/jsp/async/

and that is when Tomcat will actually generate a real response,
because this time it is a correct URL. So the response appears to the
browser, as coming from

   http://localhost:8080/examples/jsp/async/

which is correct.

2) http://localhost:8080/mypath/async/

This also matches the rewrite rule, so it gets rewritten to

http://localhost:8080/examples/jsp/async/

which is a correct URL.
Thus Tomcat will immediately generate a real response (without an
intermediate 302 redirect), which will be appear in the browser URL
bar as a response to

http://localhost:8080/mypath/async/

This is also expected behaviour.

I believe that if you do not want to see the first redirect URL

   http://localhost:8080/examples/jsp/async/

in the browser, you have to modify your rewrite rules, perhaps by
using a RewriteCond with the -d flag, to check first if the URL 
points

to an existing directory, and if yes add the terminating / yourself
(with a RewriteRule) before other rewrite tests/rules take place

Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-19 Thread Jérémie Barthés

Hi Chris,

When an URL target a folder on the server, tomcat automaticly add a / 
at the end of the URL if missing :
myHost.com/myFolder = myHost.com/myFolder/ (automatic tomcat 302 
redirection)


If you use a rewriteValve to forward myHost.com/myFolder to 
myHost.com/rewriteTrick/myFolder,
the rewriteValve will forward simultaneous with the automatic tomcat 
redirection. Then the client's browser will catch the rewritten URL (you 
don't want

the rewritten URL to be visible for the client's browser).
myHost.com/myFolder
redirect to
myHost.com/rewriteTrick/myFolder/ (visible)

So i made a patch to block the RewriteValve if an automatic 302 tomcat 
redirection is applied. Then the RewriteValve forward in a second time 
and the rewritten URL is not visible for the client's Browser :

myHost.com/myFolder
redirect to
myHost.com/myFolder/
forward to
myHost/rewriteTrick/myFolder/ (not visible)

It may be a configuration mistake of my part. I tried many different 
configurations to avoid it but i wasn't able without coding a patch.


Regards

Jérémie




Le 17/02/2015 19:39, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 2/17/15 10:47 AM, Jérémie Barthés wrote:

I don't have more to say than :

There is a bug using the RewriteValve :If you are targeting a
folder and there is no / at the end of the URI,

The end of which URI? The one in the rewrite rule? Or the one the
client sends in the URL?


the rewritten URI is visible for the client browser (302
redirection). Example : http://myhost.com/myFolder =
http://myhost.com/rewriteTrick/myFolder/ instead of
http://myhost.com/myFolder = http://myhost.com/myFolder/;

It looks like in this case, the rewrite rule isn't matching, and the
DefaultServlet is performing redirection instead. This sounds like a
configuration mistake on your part, not a bug in the rewrite valve.


The bug is solved for me. I just wanted to tell developers about
it.

- -chris


Le 17/02/2015 15:34, Christopher Schultz a écrit : Jérémie,

On 2/17/15 6:20 AM, Jérémie Barthés wrote:

I just installed tomcat 8 and used the RewriteValve to
forward some old URLs on my new tomcat8 webapp. I had an
issue for URIs targeting a folder: If there is no / at the
end of the URI, the rewritten URI is visible for the client
browser (302 redirection). Example :
http://myhost.com/myFolder =
http://myhost.com/rewriteTrick/myFolder/ instead of
http://myhost.com/myFolder = http://myhost.com/myFolder/

I made a custom patch on RewriteValve to solve it. I would
like to know if it'll be corrected on next releases. (i tried
on 8.0.18 but there is still the issue)

Regards,

Jeremie Barthes Oodrive France



Between lines 480 and 500 :

boolean folderRedirect = false; try{
request.getMappingData().recycle();

request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(),




request.getCoyoteRequest().requestURI(),

null, request.getMappingData());

if(request.getMappingData().redirectPath.toString()!=null){
folderRedirect = true; } } catch (Exception e){ //ignore }

request.getMappingData().recycle(); // Reinvoke the whole
request recursively try {

request.getConnector().getProtocolHandler().getAdapter().service



(request.getCoyoteRequest(), response.getCoyoteResponse());

if(folderRedirect  response.getCoyoteResponse().getStatus()
== 302){

if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith(/)){





String requestParam = request.getQueryString() == null ?  : '?'

+ request.getQueryString(); response.setHeader(Location,
request.getCoyoteRequest().requestURI().getByteChunk().toString()
+ '/' + requestParam); } } } catch (Exception e) { // This
doesn't actually happen in the Catalina adapter
implementation }

The best practice would be to file an enhancement request in
Bugzilla, write and attach a test case that demonstrates the
problem (or describe it in very great detail... from the above, I
don't know what you have changed and why), and attach your changes
(as a patch, using svn diff or something similar) to the Bugzilla
issue.

-chris

-



To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

For additional commands, e-mail: users-h...@tomcat.apache.org



-



To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

For additional commands, e-mail: users-h...@tomcat.apache.org


-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU44rQAAoJEBzwKT+lPKRYLwEQAJgAdh33TnTRbkRtBfugTc5D
8VwtHftAfL6ykdbGTYllInSfhxZkWH3fA7gxqBb18TaICqw0sxAVg1TaKIjtEwYb
TQzxryNJQsg1fJ97L56EauRJyKikO0OTE7XUT8S5TIr/Z0YuhfQzIOKA+KvzyiUE
rDbJ4N4TA41fvgA7aCdeQluDGJ/sOnFVotq5sSp6j41XSCAfWXrg8r+FlVegPJm8
fblHS3E19PTvv/IuJaNDPefafpdLoyiMYnfPgC8MKYbfipUCJLyl30ZTjiBw2Jmi
9SGqPFkk9y2Yk72R5ihL1dExb332nBwV7xZIVJsyDysKWW2OYI/XY7BYwSW8rguA

Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-19 Thread Jérémie Barthés

Tell me what you need about my configuration :

rewrite.config file :
RewriteRule^/jamfiles/(.*)$/newapp/jamfiles/$1
RewriteRule^/workspace/(.*)$ /newapp/htdocuments/workspace/$1
RewriteRule ^/([a-zA-Z0-9]+)(\.jsp|\.html|\.txt)$ /newapp/htdocuments/$1$2

tomcat version : 8.0.15 (tried on 8.0.18 too)

Operating System : tried on windows 7 and unix

Le 19/02/2015 15:15, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 2/19/15 4:54 AM, Jérémie Barthés wrote:

When an URL target a folder on the server, tomcat automaticly add a
/ at the end of the URL if missing : myHost.com/myFolder =
myHost.com/myFolder/ (automatic tomcat 302 redirection)

If you use a rewriteValve to forward myHost.com/myFolder to
myHost.com/rewriteTrick/myFolder, the rewriteValve will forward
simultaneous with the automatic tomcat redirection. Then the
client's browser will catch the rewritten URL (you don't want the
rewritten URL to be visible for the client's browser).
myHost.com/myFolder redirect to myHost.com/rewriteTrick/myFolder/
(visible)

So i made a patch to block the RewriteValve if an automatic 302
tomcat redirection is applied. Then the RewriteValve forward in a
second time and the rewritten URL is not visible for the client's
Browser : myHost.com/myFolder redirect to myHost.com/myFolder/
forward to myHost/rewriteTrick/myFolder/ (not visible)

It may be a configuration mistake of my part. I tried many
different configurations to avoid it but i wasn't able without
coding a patch.

It /may/ be a configuration problem. We won't know until you post your
configuration.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU5e/qAAoJEBzwKT+lPKRYPaAP/jtr2XC2ZViVzUDK44Fqcl+P
q1LRRKO112Hzv+p35kUAPFQn2YyvJamqH7dnl6rVnBIY5YviBCNqJdpn48fpe78E
B/T5nr9WOfdMxg9fBgMG78L+ihJzKgiZpXGgVvR68RLuYgeWPhnur2I3Xcj4rLRc
Nd9aWX/vHX3aLoh3ThTUKIWVmaiK8a5JP240W/5g65OE07Tnc/albiBHvTdGbEBQ
LoLKmp315mZLDkzzNIsu7Lbbz8DtDrJo+Oaos1Fm3CUBM5ULO0hwcFr1IyxL2Tvk
1S8ZGHaDvFQF0II0pf9P8MgpDfK1st1rGp86k1B3e1KMt7gWFytOZwPgJLwCDqVe
VAfgE4VpnJ8aBtVAKc1vTpNpP4X4xuFuKl93OtAbaFa9mBhdfetbeCo7OLogeSB+
UZj3PQnM7rLoyllXtEx4hGSDy+AU3o/S7JqXrJdbHMqt1v/BmEd/ZsdAYCOa+lmb
JEkxPUG+EPTMxyiCrw498KjY2q5Z9naA/IecIHdPGa7u2TwIlkMCJazCtBEmSu8d
VfDQyxR1f+eExsTa3i8eIjdw+z/hTsgMJYi0qiI2slkWOp99N9xWNdH/W5UdHKWf
Qb8fefesWyKQof0voqWPbOXOFdgcJqXs26K1gxRM9rZSzfV990Ooizohg/DfGYjG
Y2AZNcubxOPam0aEVct9
=ClXj
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-19 Thread Jérémie Barthés

Hi,

I made a scenario to make the issue happens :

Use a tomcat 8.0.18

Make a file rewrite.config in conf/Catalina/localhost/ that contains :
RewriteRule^/mypath/(.*)$/examples/jsp/$1

copy the line
Valve 
className=org.apache.catalina.valves.rewrite.RewriteValve /

in the conf/server.xml file, line 131

launch the server

try the followings URLs :
http://localhost:8080/mypath/async
http://localhost:8080/mypath/async/

the result i have is :
http://localhost:8080/mypath/async = 
http://localhost:8080/examples/jsp/async/ (visible rewrite)

http://localhost:8080/mypath/async/ = http://localhost:8080/mypath/async/

Jérémie



Le 19/02/2015 15:25, Jérémie Barthés a écrit :

Tell me what you need about my configuration :

rewrite.config file :
RewriteRule^/jamfiles/(.*)$/newapp/jamfiles/$1
RewriteRule^/workspace/(.*)$ /newapp/htdocuments/workspace/$1
RewriteRule ^/([a-zA-Z0-9]+)(\.jsp|\.html|\.txt)$ 
/newapp/htdocuments/$1$2


tomcat version : 8.0.15 (tried on 8.0.18 too)

Operating System : tried on windows 7 and unix

Le 19/02/2015 15:15, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 2/19/15 4:54 AM, Jérémie Barthés wrote:

When an URL target a folder on the server, tomcat automaticly add a
/ at the end of the URL if missing : myHost.com/myFolder =
myHost.com/myFolder/ (automatic tomcat 302 redirection)

If you use a rewriteValve to forward myHost.com/myFolder to
myHost.com/rewriteTrick/myFolder, the rewriteValve will forward
simultaneous with the automatic tomcat redirection. Then the
client's browser will catch the rewritten URL (you don't want the
rewritten URL to be visible for the client's browser).
myHost.com/myFolder redirect to myHost.com/rewriteTrick/myFolder/
(visible)

So i made a patch to block the RewriteValve if an automatic 302
tomcat redirection is applied. Then the RewriteValve forward in a
second time and the rewritten URL is not visible for the client's
Browser : myHost.com/myFolder redirect to myHost.com/myFolder/
forward to myHost/rewriteTrick/myFolder/ (not visible)

It may be a configuration mistake of my part. I tried many
different configurations to avoid it but i wasn't able without
coding a patch.

It /may/ be a configuration problem. We won't know until you post your
configuration.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU5e/qAAoJEBzwKT+lPKRYPaAP/jtr2XC2ZViVzUDK44Fqcl+P
q1LRRKO112Hzv+p35kUAPFQn2YyvJamqH7dnl6rVnBIY5YviBCNqJdpn48fpe78E
B/T5nr9WOfdMxg9fBgMG78L+ihJzKgiZpXGgVvR68RLuYgeWPhnur2I3Xcj4rLRc
Nd9aWX/vHX3aLoh3ThTUKIWVmaiK8a5JP240W/5g65OE07Tnc/albiBHvTdGbEBQ
LoLKmp315mZLDkzzNIsu7Lbbz8DtDrJo+Oaos1Fm3CUBM5ULO0hwcFr1IyxL2Tvk
1S8ZGHaDvFQF0II0pf9P8MgpDfK1st1rGp86k1B3e1KMt7gWFytOZwPgJLwCDqVe
VAfgE4VpnJ8aBtVAKc1vTpNpP4X4xuFuKl93OtAbaFa9mBhdfetbeCo7OLogeSB+
UZj3PQnM7rLoyllXtEx4hGSDy+AU3o/S7JqXrJdbHMqt1v/BmEd/ZsdAYCOa+lmb
JEkxPUG+EPTMxyiCrw498KjY2q5Z9naA/IecIHdPGa7u2TwIlkMCJazCtBEmSu8d
VfDQyxR1f+eExsTa3i8eIjdw+z/hTsgMJYi0qiI2slkWOp99N9xWNdH/W5UdHKWf
Qb8fefesWyKQof0voqWPbOXOFdgcJqXs26K1gxRM9rZSzfV990Ooizohg/DfGYjG
Y2AZNcubxOPam0aEVct9
=ClXj
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-17 Thread Jérémie Barthés

Hi,

I don't have more to say than :

There is a bug using the RewriteValve :If you are targeting a folder and there is no 
/ at the end of the URI,
the rewritten URI is visible for the client browser (302 redirection).
Example :
http://myhost.com/myFolder = http://myhost.com/rewriteTrick/myFolder/
instead of
http://myhost.com/myFolder = http://myhost.com/myFolder/;


The bug is solved for me.
I just wanted to tell developpers about it.

Regards

Jérémie


Le 17/02/2015 15:34, Christopher Schultz a écrit :

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jérémie,

On 2/17/15 6:20 AM, Jérémie Barthés wrote:

I just installed tomcat 8 and used the RewriteValve to forward some
old URLs on my new tomcat8 webapp. I had an issue for URIs
targeting a folder: If there is no / at the end of the URI, the
rewritten URI is visible for the client browser (302 redirection).
Example : http://myhost.com/myFolder =
http://myhost.com/rewriteTrick/myFolder/ instead of
http://myhost.com/myFolder = http://myhost.com/myFolder/

I made a custom patch on RewriteValve to solve it. I would like to
know if it'll be corrected on next releases. (i tried on 8.0.18 but
there is still the issue)

Regards,

Jeremie Barthes Oodrive France



Between lines 480 and 500 :

boolean folderRedirect = false; try{
request.getMappingData().recycle();

request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(),



request.getCoyoteRequest().requestURI(),

null, request.getMappingData());

if(request.getMappingData().redirectPath.toString()!=null){
folderRedirect = true; } } catch (Exception e){ //ignore }

request.getMappingData().recycle(); // Reinvoke the whole request
recursively try {

request.getConnector().getProtocolHandler().getAdapter().service
(request.getCoyoteRequest(), response.getCoyoteResponse());
if(folderRedirect  response.getCoyoteResponse().getStatus() ==
302){

if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith(/)){

  String requestParam = request.getQueryString() == null ?  : '?'
+ request.getQueryString(); response.setHeader(Location,
request.getCoyoteRequest().requestURI().getByteChunk().toString() +
'/' + requestParam); } } } catch (Exception e) { // This doesn't
actually happen in the Catalina adapter implementation }

The best practice would be to file an enhancement request in Bugzilla,
write and attach a test case that demonstrates the problem (or
describe it in very great detail... from the above, I don't know what
you have changed and why), and attach your changes (as a patch, using
svn diff or something similar) to the Bugzilla issue.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU41FiAAoJEBzwKT+lPKRYJVwP/0txV+MSHwzl4FQjRWd2gaOS
V+l0b7CIXI77lHr+xuC6A/OqqpJHNPZjYWIqtCaeDvq/eFc8eVXczV8C6CV1NWN5
b9dQdBTw4/+bC/JNg2XlWkwlbeW08eNqeX77F1zXhSoBEUuZrRcmy/sZXsa4g9x8
XusQqrjpjc5KvZOkUqJbazbKO86o7kRrOuVNVXR0MHtpmBMOkCI0WKht+RpsA3DN
fH0Qd+eo0xtmU0YNSMURr6Z8y+yi3v/pNx4tBQ5ijEAHXB8f9SolfObt63OrcTh3
I347ZIEESfkeqxqBqImJkeRsqvlx2pv2ChF0fm638vgiYFXU+a4xYLP45ovR0wg6
c4P0GYK3mE2yieQjio3zAj/Z9Qc4DW39FJNIeU1zYY+73yzkn28CprW6nn9eaRvf
cz+vaU2IamD/e4vJgHpiB5vewwaZSx1a81OkpDn8O7xWyO4azp4eViA2K5jwM2Cf
LL7/fztfJoapob+polncNECb3Bi3aT/yKeI9tbunb7x8jCHqIBWtGrvKJ0U5q25U
XzH1Wk6EZCtYhiYXQvyPoktKmXfDuayMiq+IexdMBic+I/Uqv5scQuFrjEZVlFj+
hSNd9OpPQwXKL7ScFAyznw6R4h5yzPZyW01KtO1jVek1oOOdIRI7PxLRgJReh6j0
78GINeUMF8NCRkYY4/sf
=zX1T
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Issue with RewriteValve and folders (tomcat 8.0.15)

2015-02-17 Thread Jérémie Barthés


Hi,

I just installed tomcat 8 and used the RewriteValve to forward some old
URLs on my new tomcat8 webapp. I had an issue for URIs targeting a
folder: If there is no / at the end of the URI, the rewritten URI is
visible for the client browser (302 redirection).
Example :
http://myhost.com/myFolder = http://myhost.com/rewriteTrick/myFolder/
instead of
http://myhost.com/myFolder = http://myhost.com/myFolder/

I made a custom patch on RewriteValve to solve it. I would like to know if 
it'll be corrected on next releases. (i tried on 8.0.18 but there is still the 
issue)

Regards,

Jeremie Barthes
Oodrive France



Between lines 480 and 500 :

  boolean folderRedirect = false;
try{
request.getMappingData().recycle();

request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(),
 request.getCoyoteRequest().requestURI(),
null, request.getMappingData());

if(request.getMappingData().redirectPath.toString()!=null){
folderRedirect = true;
}
} catch (Exception e){
//ignore
}

request.getMappingData().recycle();
// Reinvoke the whole request recursively
try {

request.getConnector().getProtocolHandler().getAdapter().service
(request.getCoyoteRequest(), 
response.getCoyoteResponse());

if(folderRedirect  response.getCoyoteResponse().getStatus() == 302){


if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith(/)){
String requestParam = request.getQueryString() == 
null ?  : '?' + request.getQueryString();
response.setHeader(Location, 
request.getCoyoteRequest().requestURI().getByteChunk().toString() + '/' + requestParam);
}
}
} catch (Exception e) {
// This doesn't actually happen in the Catalina adapter 
implementation
}

 







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org