From 14162c61548306efd9f68b3dd774c3ad885f5a3f Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 22 Nov 2012 16:09:44 +1100 Subject: [PATCH] 394514 Preserve URI parameters in sendRedirect --- .../java/org/eclipse/jetty/server/Response.java | 16 ++++++++++++---- .../org/eclipse/jetty/server/ResponseTest.java | 17 +++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index 49f6d1551dc..c4d4c50c8ac 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -468,15 +468,23 @@ public class Response implements HttpServletResponse { buf = _connection.getRequest().getRootURL(); buf.append(URIUtil.encodePath(canonical)); - if (uri.getQuery()!=null) + String param=uri.getParam(); + if (param!=null) + { + buf.append(';'); + buf.append(param); + } + String query=uri.getQuery(); + if (query!=null) { buf.append('?'); - buf.append(uri.getQuery()); + buf.append(query); } - if (uri.getFragment()!=null) + String fragment=uri.getFragment(); + if (fragment!=null) { buf.append('#'); - buf.append(uri.getFragment()); + buf.append(fragment); } location=buf.toString(); } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java index 0c205b0bfc9..9599f670f69 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java @@ -423,8 +423,13 @@ public class ResponseTest throws Exception { String[][] tests={ - {"/other/location?name=value","http://myhost:8888/other/location;jsessionid=12345?name=value"}, - /* {"/other/location","http://myhost:8888/other/location"}, + // No cookie + {"http://myhost:8888/other/location;jsessionid=12345?name=value","http://myhost:8888/other/location;jsessionid=12345?name=value"}, + {"/other/location;jsessionid=12345?name=value","http://myhost:8888/other/location;jsessionid=12345?name=value"}, + {"./location;jsessionid=12345?name=value","http://myhost:8888/path/location;jsessionid=12345?name=value"}, + + // From cookie + {"/other/location","http://myhost:8888/other/location"}, {"/other/l%20cation","http://myhost:8888/other/l%20cation"}, {"location","http://myhost:8888/path/location"}, {"./location","http://myhost:8888/path/location"}, @@ -432,11 +437,11 @@ public class ResponseTest {"/other/l%20cation","http://myhost:8888/other/l%20cation"}, {"l%20cation","http://myhost:8888/path/l%20cation"}, {"./l%20cation","http://myhost:8888/path/l%20cation"}, - {"../l%20cation","http://myhost:8888/l%20cation"},*/ + {"../l%20cation","http://myhost:8888/l%20cation"}, {"../locati%C3%abn","http://myhost:8888/locati%C3%ABn"}, }; - for (int i=1;i0); + request.setRequestedSessionIdFromCookie(i>2); AbstractSessionManager manager=new HashSessionManager(); manager.setSessionIdManager(new HashSessionIdManager()); request.setSessionManager(manager); @@ -460,7 +465,7 @@ public class ResponseTest int l=location.indexOf("Location: "); int e=location.indexOf('\n',l); location=location.substring(l+10,e).trim(); - assertEquals(tests[i][0],tests[i][1],location); + assertEquals("test-"+i,tests[i][1],location); } }