From 82a02c578caeefcb7b6987f2d3f20b1712f754aa Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 21 Jun 2012 10:52:40 -0500 Subject: [PATCH] [Bug 383251] resolve npe and return 500 when remote server is unaccessible --- .../server/handler/ConnectHandlerTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java index 7b4ba467ab6..a4caf945de1 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java @@ -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 {