Merge remote-tracking branch 'origin/master' into jetty-http2

Conflicts:
	jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
	jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
This commit is contained in:
Greg Wilkins 2014-07-16 17:23:29 +10:00
commit 6893027ecd
5 changed files with 35 additions and 20 deletions

View File

@ -539,8 +539,6 @@ public class HttpURI
{
if (_host==_port)
return null;
if (_raw[_host]=='[')
return new String(_raw,_host+1,_port-_host-2,_charset);
return new String(_raw,_host,_port-_host,_charset);
}

View File

@ -33,9 +33,9 @@ public class HttpURITest
{
{"/path/to/context",null,null,"-1","/path/to/context",null,null,null},
{"http://example.com/path/to/context;param?query=%22value%22#fragment","http","example.com","-1","/path/to/context","param","query=%22value%22","fragment"},
{"http://[::1]/path/to/context;param?query=%22value%22#fragment","http","::1","-1","/path/to/context","param","query=%22value%22","fragment"},
{"http://[::1]/path/to/context;param?query=%22value%22#fragment","http","[::1]","-1","/path/to/context","param","query=%22value%22","fragment"},
{"http://example.com:8080/path/to/context;param?query=%22value%22#fragment","http","example.com","8080","/path/to/context","param","query=%22value%22","fragment"},
{"http://[::1]:8080/path/to/context;param?query=%22value%22#fragment","http","::1","8080","/path/to/context","param","query=%22value%22","fragment"},
{"http://[::1]:8080/path/to/context;param?query=%22value%22#fragment","http","[::1]","8080","/path/to/context","param","query=%22value%22","fragment"},
};
public static int

View File

@ -136,11 +136,11 @@ public class HttpURITest
/*33*/ {"/?abc=test",null, null, null,null,"/", null,"abc=test",null},
/*34*/ {"/#fragment",null, null, null,null,"/", null,null,"fragment"},
/*35*/ {"http://192.0.0.1:8080/","http","//192.0.0.1:8080","192.0.0.1","8080","/",null,null,null},
/*36*/ {"http://[2001:db8::1]:8080/","http","//[2001:db8::1]:8080","2001:db8::1","8080","/",null,null,null},
/*37*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","2001:db8::1","8080","/",null,null,null},
/*38*/ {"http://[2001:db8::1]/","http","//[2001:db8::1]","2001:db8::1",null,"/",null,null,null},
/*36*/ {"http://[2001:db8::1]:8080/","http","//[2001:db8::1]:8080","[2001:db8::1]","8080","/",null,null,null},
/*37*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","[2001:db8::1]","8080","/",null,null,null},
/*38*/ {"http://[2001:db8::1]/","http","//[2001:db8::1]","[2001:db8::1]",null,"/",null,null,null},
/*39*/ {"//[2001:db8::1]:8080/",null,null,null,null,"//[2001:db8::1]:8080/",null,null,null},
/*40*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","2001:db8::1","8080","/",null,null,null},
/*40*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","[2001:db8::1]","8080","/",null,null,null},
/*41*/ {"*",null,null,null,null,"*",null, null,null}
};
@ -353,7 +353,7 @@ public class HttpURITest
{
/* 0*/ {" localhost:8080 ","localhost","8080"},
/* 1*/ {" 127.0.0.1:8080 ","127.0.0.1","8080"},
/* 2*/ {" [127::0::0::1]:8080 ","127::0::0::1","8080"},
/* 2*/ {" [127::0::0::1]:8080 ","[127::0::0::1]","8080"},
/* 3*/ {" error ",null,null},
/* 4*/ {" http://localhost:8080/ ",null,null},
};

View File

@ -116,8 +116,6 @@ public class ServletHandler extends ScopedHandler
private ServletHolder[] _servlets=new ServletHolder[0];
private ServletMapping[] _servletMappings;
private Map<String,ServletMapping> _servletPathMappings = new HashMap<String,ServletMapping>();
private final Map<String,FilterHolder> _filterNameMap= new HashMap<>();
private List<FilterMapping> _filterPathMappings;
private MultiMap<FilterMapping> _filterNameMappings;
@ -340,7 +338,6 @@ public class ServletHandler extends ScopedHandler
_filterPathMappings=null;
_filterNameMappings=null;
_servletPathMap=null;
_servletPathMappings=null;
}
/* ------------------------------------------------------------ */
@ -415,10 +412,26 @@ public class ServletHandler extends ScopedHandler
*/
public ServletMapping getServletMapping(String pathSpec)
{
if (pathSpec == null || _servletPathMappings == null)
if (pathSpec == null || _servletMappings == null)
return null;
return _servletPathMappings.get(pathSpec);
ServletMapping mapping = null;
for (int i=0; i<_servletMappings.length && mapping == null; i++)
{
ServletMapping m = _servletMappings[i];
if (m.getPathSpecs() != null)
{
for (String p:m.getPathSpecs())
{
if (pathSpec.equals(p))
{
mapping = m;
break;
}
}
}
}
return mapping;
}
/* ------------------------------------------------------------ */
@ -1443,9 +1456,7 @@ public class ServletHandler extends ScopedHandler
//for each path, look at the mappings where it is referenced
//if a mapping is for a servlet that is not enabled, skip it
Set<ServletMapping> mappings = sms.get(pathSpec);
ServletMapping finalMapping = null;
for (ServletMapping mapping : mappings)
{
@ -1483,7 +1494,6 @@ public class ServletHandler extends ScopedHandler
}
_servletPathMap=pm;
_servletPathMappings=servletPathMappings;
}
// flush filter chain cache
@ -1542,7 +1552,7 @@ public class ServletHandler extends ScopedHandler
{
updateBeans(_filterMappings,filterMappings);
_filterMappings = filterMappings;
updateMappings();
if (isStarted()) updateMappings();
invalidateChainsCache();
}
@ -1567,7 +1577,7 @@ public class ServletHandler extends ScopedHandler
{
updateBeans(_servletMappings,servletMappings);
_servletMappings = servletMappings;
updateMappings();
if (isStarted()) updateMappings();
invalidateChainsCache();
}

View File

@ -335,6 +335,7 @@ public class ServletHandlerTest
//add a non-programmatic one to begin with
handler.addFilterWithMapping(fh1, "/*", EnumSet.allOf(DispatcherType.class));
handler.updateMappings();
FilterMapping[] mappings = handler.getFilterMappings();
assertNotNull(mappings);
assertTrue(fh1 == mappings[0].getFilterHolder());
@ -343,6 +344,7 @@ public class ServletHandlerTest
fh4.setServletHandler(handler);
handler.addFilter(fh4);
fh4.getRegistration().addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
handler.updateMappings();
mappings = handler.getFilterMappings();
assertNotNull(mappings);
assertEquals(2, mappings.length);
@ -353,6 +355,7 @@ public class ServletHandlerTest
fh3.setServletHandler(handler);
handler.addFilter(fh3);
fh3.getRegistration().addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
handler.updateMappings();
mappings = handler.getFilterMappings();
assertNotNull(mappings);
assertEquals(3, mappings.length);
@ -364,6 +367,7 @@ public class ServletHandlerTest
fh5.setServletHandler(handler);
handler.addFilter(fh5);
fh5.getRegistration().addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
handler.updateMappings();
mappings = handler.getFilterMappings();
assertNotNull(mappings);
assertEquals(4, mappings.length);
@ -376,6 +380,7 @@ public class ServletHandlerTest
FilterHolder f = new FilterHolder(Source.EMBEDDED);
f.setName("non-programmatic");
handler.addFilterWithMapping(f, "/*", EnumSet.allOf(DispatcherType.class));
handler.updateMappings();
mappings = handler.getFilterMappings();
assertNotNull(mappings);
assertEquals(5, mappings.length);
@ -391,6 +396,7 @@ public class ServletHandlerTest
pf.setName("programmaticA");
handler.addFilter(pf);
pf.getRegistration().addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
handler.updateMappings();
mappings = handler.getFilterMappings();
assertNotNull(mappings);
assertEquals(6, mappings.length);
@ -407,6 +413,7 @@ public class ServletHandlerTest
pf2.setName("programmaticB");
handler.addFilter(pf2);
pf2.getRegistration().addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
handler.updateMappings();
mappings = handler.getFilterMappings();
assertNotNull(mappings);