Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
8ca8735c95
|
@ -638,27 +638,6 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
||||||
if (_log.isDebugEnabled())
|
if (_log.isDebugEnabled())
|
||||||
_log.debug(getRequestId(clientRequest) + " proxying failed", failure);
|
_log.debug(getRequestId(clientRequest) + " proxying failed", failure);
|
||||||
|
|
||||||
if (proxyResponse.isCommitted())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Use Jetty specific behavior to close connection.
|
|
||||||
proxyResponse.sendError(-1);
|
|
||||||
if (clientRequest.isAsyncStarted())
|
|
||||||
{
|
|
||||||
AsyncContext asyncContext = clientRequest.getAsyncContext();
|
|
||||||
asyncContext.complete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable x)
|
|
||||||
{
|
|
||||||
if (_log.isDebugEnabled())
|
|
||||||
_log.debug(getRequestId(clientRequest) + " could not close the connection", failure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
proxyResponse.resetBuffer();
|
|
||||||
int status = failure instanceof TimeoutException ?
|
int status = failure instanceof TimeoutException ?
|
||||||
HttpStatus.GATEWAY_TIMEOUT_504 :
|
HttpStatus.GATEWAY_TIMEOUT_504 :
|
||||||
HttpStatus.BAD_GATEWAY_502;
|
HttpStatus.BAD_GATEWAY_502;
|
||||||
|
@ -666,7 +645,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
||||||
if (expects100Continue(clientRequest) && serverStatus >= HttpStatus.OK_200)
|
if (expects100Continue(clientRequest) && serverStatus >= HttpStatus.OK_200)
|
||||||
status = serverStatus;
|
status = serverStatus;
|
||||||
sendProxyResponseError(clientRequest, proxyResponse, status);
|
sendProxyResponseError(clientRequest, proxyResponse, status);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getRequestId(HttpServletRequest clientRequest)
|
protected int getRequestId(HttpServletRequest clientRequest)
|
||||||
|
@ -676,11 +655,25 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
||||||
|
|
||||||
protected void sendProxyResponseError(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, int status)
|
protected void sendProxyResponseError(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, int status)
|
||||||
{
|
{
|
||||||
proxyResponse.setStatus(status);
|
try
|
||||||
|
{
|
||||||
|
if (!proxyResponse.isCommitted())
|
||||||
|
{
|
||||||
|
proxyResponse.resetBuffer();
|
||||||
proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
|
proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
|
||||||
|
}
|
||||||
|
proxyResponse.sendError(status);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
_log.ignore(e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
if (clientRequest.isAsyncStarted())
|
if (clientRequest.isAsyncStarted())
|
||||||
clientRequest.getAsyncContext().complete();
|
clientRequest.getAsyncContext().complete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void onContinue(HttpServletRequest clientRequest, Request proxyRequest)
|
protected void onContinue(HttpServletRequest clientRequest, Request proxyRequest)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1087,10 +1087,10 @@ public class ProxyServletTest
|
||||||
Response response = listener.get(5, TimeUnit.SECONDS);
|
Response response = listener.get(5, TimeUnit.SECONDS);
|
||||||
Assert.assertEquals(504, response.getStatus());
|
Assert.assertEquals(504, response.getStatus());
|
||||||
|
|
||||||
// Make sure there is no content, as the proxy-to-client response has been reset.
|
// Make sure there is error page content, as the proxy-to-client response has been reset.
|
||||||
InputStream input = listener.getInputStream();
|
InputStream input = listener.getInputStream();
|
||||||
Assert.assertEquals(-1, input.read());
|
String body = IO.toString(input);
|
||||||
|
Assert.assertThat(body,Matchers.containsString("HTTP ERROR: 504"));
|
||||||
chunk1Latch.countDown();
|
chunk1Latch.countDown();
|
||||||
|
|
||||||
// Result succeeds because a 504 is a valid HTTP response.
|
// Result succeeds because a 504 is a valid HTTP response.
|
||||||
|
|
|
@ -250,7 +250,7 @@ public class InetAddressSet extends AbstractSet<String> implements Set<String>,
|
||||||
if (cidr>(_raw.length*8))
|
if (cidr>(_raw.length*8))
|
||||||
throw new IllegalArgumentException("CIDR too large: "+pattern);
|
throw new IllegalArgumentException("CIDR too large: "+pattern);
|
||||||
|
|
||||||
if (_mask!=0 && _raw[_octets]!=_masked)
|
if (_mask!=0 && (0xff&_raw[_octets])!=_masked)
|
||||||
throw new IllegalArgumentException("CIDR bits non zero: "+pattern);
|
throw new IllegalArgumentException("CIDR bits non zero: "+pattern);
|
||||||
|
|
||||||
for (int o=_octets+(_mask==0?0:1);o<_raw.length;o++)
|
for (int o=_octets+(_mask==0?0:1);o<_raw.length;o++)
|
||||||
|
|
|
@ -134,8 +134,21 @@ public class InetAddressSetTest
|
||||||
|
|
||||||
set.add("0.0.0.0/0");
|
set.add("0.0.0.0/0");
|
||||||
assertTrue(set.test(InetAddress.getByName("10.11.0.0")));
|
assertTrue(set.test(InetAddress.getByName("10.11.0.0")));
|
||||||
|
|
||||||
|
// test #1664
|
||||||
|
set.add("2.144.0.0/14");
|
||||||
|
set.add("2.176.0.0/12");
|
||||||
|
set.add("5.22.0.0/17");
|
||||||
|
set.add("5.22.192.0/19");
|
||||||
|
assertTrue(set.test(InetAddress.getByName("2.144.0.1")));
|
||||||
|
assertTrue(set.test(InetAddress.getByName("2.176.0.1")));
|
||||||
|
assertTrue(set.test(InetAddress.getByName("5.22.0.1")));
|
||||||
|
assertTrue(set.test(InetAddress.getByName("5.22.192.1")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBadCIDR() throws Exception
|
public void testBadCIDR() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue