Merge branch 'jetty-8' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-8
This commit is contained in:
commit
9cba806b31
|
@ -146,7 +146,16 @@ public class PathMap extends HashMap implements Externalizable
|
|||
@Override
|
||||
public Object put(Object pathSpec, Object object)
|
||||
{
|
||||
StringTokenizer tok = new StringTokenizer(pathSpec.toString(),__pathSpecSeparators);
|
||||
String str = pathSpec.toString();
|
||||
if ("".equals(str.trim()))
|
||||
{
|
||||
Entry entry = new Entry("",object);
|
||||
entry.setMapped("");
|
||||
_exactMap.put("", entry);
|
||||
return super.put("", object);
|
||||
}
|
||||
|
||||
StringTokenizer tok = new StringTokenizer(str,__pathSpecSeparators);
|
||||
Object old =null;
|
||||
|
||||
while (tok.hasMoreTokens())
|
||||
|
@ -218,13 +227,21 @@ public class PathMap extends HashMap implements Externalizable
|
|||
*/
|
||||
public Entry getMatch(String path)
|
||||
{
|
||||
Map.Entry entry;
|
||||
Map.Entry entry=null;
|
||||
|
||||
if (path==null)
|
||||
return null;
|
||||
|
||||
int l=path.length();
|
||||
|
||||
|
||||
//special case
|
||||
if (l == 1 && path.charAt(0)=='/')
|
||||
{
|
||||
entry = (Map.Entry)_exactMap.get("");
|
||||
if (entry != null)
|
||||
return (Entry)entry;
|
||||
}
|
||||
|
||||
// try exact match
|
||||
entry=_exactMap.getEntry(path,0,l);
|
||||
if (entry!=null)
|
||||
|
@ -455,6 +472,9 @@ public class PathMap extends HashMap implements Externalizable
|
|||
*/
|
||||
public static String pathInfo(String pathSpec, String path)
|
||||
{
|
||||
if ("".equals(pathSpec))
|
||||
return path; //servlet 3 spec sec 12.2 will be '/'
|
||||
|
||||
char c = pathSpec.charAt(0);
|
||||
|
||||
if (c=='/')
|
||||
|
|
|
@ -36,6 +36,7 @@ public class PathMapTest extends TestCase
|
|||
p.put("*.gz", "7");
|
||||
p.put("/", "8");
|
||||
p.put("/XXX:/YYY", "9");
|
||||
p.put("", "10");
|
||||
|
||||
String[][] tests = {
|
||||
{ "/abs/path", "1"},
|
||||
|
@ -68,7 +69,7 @@ public class PathMapTest extends TestCase
|
|||
assertEquals("Dir matches", "[/animal/fish/*=4, /animal/*=5, /=8]", p.getMatches("/animal/fish/").toString());
|
||||
assertEquals("Dir matches", "[/animal/fish/*=4, /animal/*=5, /=8]", p.getMatches("/animal/fish").toString());
|
||||
assertEquals("Dir matches", "[/=8]", p.getMatches("/").toString());
|
||||
assertEquals("Dir matches", "[/=8]", p.getMatches("").toString());
|
||||
assertEquals("Dir matches", "[=10, /=8]", p.getMatches("").toString());
|
||||
|
||||
assertEquals("pathMatch exact", "/Foo/bar", PathMap.pathMatch("/Foo/bar", "/Foo/bar"));
|
||||
assertEquals("pathMatch prefix", "/Foo", PathMap.pathMatch("/Foo/*", "/Foo/bar"));
|
||||
|
@ -125,6 +126,8 @@ public class PathMapTest extends TestCase
|
|||
assertTrue("!match /foo/*", !PathMap.match("/foo/*", "/bar/anything"));
|
||||
assertTrue("match *.foo", PathMap.match("*.foo", "anything.foo"));
|
||||
assertTrue("!match *.foo", !PathMap.match("*.foo", "anything.bar"));
|
||||
|
||||
assertEquals("match / with ''", "10", p.getMatch("/").getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -374,8 +374,8 @@ public class ServletHandler extends ScopedHandler
|
|||
|
||||
String servlet_path_spec=(String)entry.getKey();
|
||||
String servlet_path=entry.getMapped()!=null?entry.getMapped():PathMap.pathMatch(servlet_path_spec,target);
|
||||
String path_info=PathMap.pathInfo(servlet_path_spec,target);
|
||||
|
||||
String path_info=PathMap.pathInfo(servlet_path_spec,target);
|
||||
|
||||
if (DispatcherType.INCLUDE.equals(type))
|
||||
{
|
||||
baseRequest.setAttribute(Dispatcher.INCLUDE_SERVLET_PATH,servlet_path);
|
||||
|
@ -393,7 +393,7 @@ public class ServletHandler extends ScopedHandler
|
|||
// look for a servlet by name!
|
||||
servlet_holder=(ServletHolder)_servletNameMap.get(target);
|
||||
}
|
||||
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("servlet {}|{}|{} -> {}",baseRequest.getContextPath(),baseRequest.getServletPath(),baseRequest.getPathInfo(),servlet_holder);
|
||||
|
||||
|
|
Loading…
Reference in New Issue