Merge branch 'master' into jetty-8

This commit is contained in:
Jesse McConnell 2012-06-21 10:53:55 -05:00
commit d1ec5a151f
4 changed files with 65 additions and 7 deletions

View File

@ -3,7 +3,7 @@ This is a source checkout of the Jetty webserver.
To build, use:
mvn install
mvn clean install
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
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.

View File

@ -223,7 +223,20 @@ public class ConnectHandler extends HandlerWrapper
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
// We need to copy the data to avoid races:
@ -304,9 +317,15 @@ public class ConnectHandler extends HandlerWrapper
return new ProxyToServerConnection(context, buffer);
}
// may return null
private SocketChannel connectToServer(HttpServletRequest request, String host, int port) throws IOException
{
SocketChannel channel = connect(request, host, port);
if ( channel == null )
{
throw new IOException("unable to connector to " + host + ":" + port);
}
channel.configureBlocking(false);
return channel;
}

View File

@ -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
public void testCONNECT10AndGET() throws Exception
{
@ -355,6 +384,14 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
@Test
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);
String hostPort = "localhost:" + serverConnector.getLocalPort();
String request = "" +

View File

@ -10,7 +10,6 @@
<name>Jetty :: Project</name>
<url>${jetty.url}</url>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.url>http://www.eclipse.org/jetty</jetty.url>