Merge branch 'master' into jetty-8
This commit is contained in:
commit
d1ec5a151f
|
@ -3,7 +3,7 @@ This is a source checkout of the Jetty webserver.
|
||||||
|
|
||||||
To build, use:
|
To build, use:
|
||||||
|
|
||||||
mvn install
|
mvn clean install
|
||||||
|
|
||||||
The jetty distribution will be built in
|
The jetty distribution will be built in
|
||||||
|
|
||||||
|
@ -16,4 +16,7 @@ The tests do a lot of stress testing, and on some machines it is
|
||||||
necessary to set the file descriptor limit to greater than 2048
|
necessary to set the file descriptor limit to greater than 2048
|
||||||
for the tests to all pass successfully.
|
for the tests to all pass successfully.
|
||||||
|
|
||||||
Bypass tests by building with -Dmaven.test.skip=true but note that this will not produce some test jars that are leveraged in other places in the build.
|
Bypass tests by building with -Dmaven.test.skip=true but note
|
||||||
|
that this will not produce some test jars that are leveraged
|
||||||
|
in other places in the build.
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,20 @@ public class ConnectHandler extends HandlerWrapper
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketChannel channel = connectToServer(request, host, port);
|
SocketChannel channel;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
channel = connectToServer(request, host, port);
|
||||||
|
}
|
||||||
|
catch ( IOException ioe )
|
||||||
|
{
|
||||||
|
LOG.info("ConnectHandler: " + ioe.getMessage());
|
||||||
|
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
baseRequest.setHandled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Transfer unread data from old connection to new connection
|
// Transfer unread data from old connection to new connection
|
||||||
// We need to copy the data to avoid races:
|
// We need to copy the data to avoid races:
|
||||||
|
@ -304,9 +317,15 @@ public class ConnectHandler extends HandlerWrapper
|
||||||
return new ProxyToServerConnection(context, buffer);
|
return new ProxyToServerConnection(context, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// may return null
|
||||||
private SocketChannel connectToServer(HttpServletRequest request, String host, int port) throws IOException
|
private SocketChannel connectToServer(HttpServletRequest request, String host, int port) throws IOException
|
||||||
{
|
{
|
||||||
SocketChannel channel = connect(request, host, port);
|
SocketChannel channel = connect(request, host, port);
|
||||||
|
if ( channel == null )
|
||||||
|
{
|
||||||
|
throw new IOException("unable to connector to " + host + ":" + port);
|
||||||
|
}
|
||||||
|
|
||||||
channel.configureBlocking(false);
|
channel.configureBlocking(false);
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,35 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCONNECTBadHostPort() throws Exception
|
||||||
|
{
|
||||||
|
String hostPort = "badlocalhost:" + serverConnector.getLocalPort();
|
||||||
|
String request = "" +
|
||||||
|
"CONNECT " + hostPort + " HTTP/1.1\r\n" +
|
||||||
|
"Host: " + hostPort + "\r\n" +
|
||||||
|
"\r\n";
|
||||||
|
Socket socket = newSocket();
|
||||||
|
socket.setSoTimeout(30000);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OutputStream output = socket.getOutputStream();
|
||||||
|
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||||
|
|
||||||
|
output.write(request.getBytes("UTF-8"));
|
||||||
|
output.flush();
|
||||||
|
|
||||||
|
// Expect 500 OK from the CONNECT request
|
||||||
|
Response response = readResponse(input);
|
||||||
|
assertEquals("500", response.getCode());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCONNECT10AndGET() throws Exception
|
public void testCONNECT10AndGET() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -355,6 +384,14 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
||||||
@Test
|
@Test
|
||||||
public void testCONNECTAndPOSTWithBigBody() throws Exception
|
public void testCONNECTAndPOSTWithBigBody() throws Exception
|
||||||
{
|
{
|
||||||
|
// fails under windows and occasionally on mac due to OOME
|
||||||
|
boolean stress = Boolean.getBoolean( "STRESS" );
|
||||||
|
|
||||||
|
if (!stress)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Log.getLogger(ConnectHandler.class).setDebugEnabled(true);
|
// Log.getLogger(ConnectHandler.class).setDebugEnabled(true);
|
||||||
String hostPort = "localhost:" + serverConnector.getLocalPort();
|
String hostPort = "localhost:" + serverConnector.getLocalPort();
|
||||||
String request = "" +
|
String request = "" +
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -10,7 +10,6 @@
|
||||||
<name>Jetty :: Project</name>
|
<name>Jetty :: Project</name>
|
||||||
<url>${jetty.url}</url>
|
<url>${jetty.url}</url>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<jetty.url>http://www.eclipse.org/jetty</jetty.url>
|
<jetty.url>http://www.eclipse.org/jetty</jetty.url>
|
||||||
|
|
Loading…
Reference in New Issue