[Bug 383251] resolve npe and return 500 when remote server is unaccessible

This commit is contained in:
Jesse McConnell 2012-06-21 10:52:40 -05:00
parent 9b2d7bb9bf
commit 82a02c578c
1 changed files with 29 additions and 0 deletions

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
{