From 61b2a5c751ff34de057c2a762b8b37b77adf146f Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 15 Jul 2011 15:50:41 +1000 Subject: [PATCH] 298502 Handle 200 Connect responses with no content-length --- VERSION.txt | 2 +- .../eclipse/jetty/client/HttpConnection.java | 5 +++++ .../jetty/client/ProxyFakeTunnelTest.java | 20 +++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index d929a7d8cde..8a11a4aa404 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,5 +1,5 @@ jetty-7.5.0-SNAPSHOT - + 298502 Added test harness to demonstrate issue + + 298502 Handle 200 Connect responses with no content-length + 351516 Refactored sessions to better support nosql session managers + 351576 Do not use deprecated method File.toURL() + 352046 Need try/catch around features set in XmlParser diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index 27285017757..39d40065a60 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -567,9 +567,14 @@ public class HttpConnection extends AbstractConnection implements Dumpable @Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { + HttpExchange exchange = _exchange; if (exchange!=null) { + // handle special case for CONNECT 200 responses + if (status==HttpStatus.OK_200 && HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod())) + _parser.setHeadResponse(true); + _http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version); _status=status; exchange.getEventListener().onResponseStatus(version,status,reason); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java index c60e5a6f32b..bccfb13620e 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java @@ -118,21 +118,25 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest state=6; System.err.println("address="+address); String[] parts=address.split(":"); - String result="200 OK"; try { toserver = new Socket(parts[0],Integer.parseInt(parts[1])); + out.write(( + "HTTP/1.1 200 OK\r\n"+ + "Server: fake\r\n"+ + // "Content-Length: 0\r\n"+ + "\r\n" + ).getBytes()); } catch(IOException e) { - result="503 Unavailable"; + out.write(( + "HTTP/1.1 503 Unavailable\r\n"+ + "Server: fake\r\n"+ + "Content-Length: 0\r\n"+ + "\r\n" + ).getBytes()); } - out.write(( - "HTTP/1.1 "+result+"\r\n"+ - "Server: fake\r\n"+ - "Content-Length: 0\r\n"+ // TODO test fails without this! - "\r\n" - ).getBytes()); out.flush(); System.err.println(toserver);