Merge remote-tracking branch 'origin/jetty-7' into jetty-8

This commit is contained in:
Greg Wilkins 2012-11-22 16:35:26 +11:00
commit e42b5bf970
3 changed files with 24 additions and 10 deletions

View File

@ -469,15 +469,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();
}

View File

@ -425,8 +425,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"},
@ -434,11 +439,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;i<tests.length;i++)
for (int i=0;i<tests.length;i++)
{
ByteArrayEndPoint out=new ByteArrayEndPoint(new byte[]{},4096);
AbstractHttpConnection connection=new TestHttpConnection(connector,out, connector.getServer());
@ -449,7 +454,7 @@ public class ResponseTest
request.setUri(new HttpURI("/path/info;param;jsessionid=12345?query=0&more=1#target"));
request.setContextPath("/path");
request.setRequestedSessionId("12345");
request.setRequestedSessionIdFromCookie(i>0);
request.setRequestedSessionIdFromCookie(i>2);
AbstractSessionManager manager=new HashSessionManager();
manager.setSessionIdManager(new HashSessionIdManager());
request.setSessionManager(manager);
@ -462,7 +467,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);
}
}

View File

@ -15,6 +15,7 @@
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertEquals;