298502 Handle 200 Connect responses with no content-length

This commit is contained in:
Greg Wilkins 2011-07-15 15:50:41 +10:00
parent 6349100c9d
commit 61b2a5c751
3 changed files with 18 additions and 9 deletions

View File

@ -1,5 +1,5 @@
jetty-7.5.0-SNAPSHOT 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 + 351516 Refactored sessions to better support nosql session managers
+ 351576 Do not use deprecated method File.toURL() + 351576 Do not use deprecated method File.toURL()
+ 352046 Need try/catch around features set in XmlParser + 352046 Need try/catch around features set in XmlParser

View File

@ -567,9 +567,14 @@ public class HttpConnection extends AbstractConnection implements Dumpable
@Override @Override
public void startResponse(Buffer version, int status, Buffer reason) throws IOException public void startResponse(Buffer version, int status, Buffer reason) throws IOException
{ {
HttpExchange exchange = _exchange; HttpExchange exchange = _exchange;
if (exchange!=null) 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); _http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version);
_status=status; _status=status;
exchange.getEventListener().onResponseStatus(version,status,reason); exchange.getEventListener().onResponseStatus(version,status,reason);

View File

@ -118,21 +118,25 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest
state=6; state=6;
System.err.println("address="+address); System.err.println("address="+address);
String[] parts=address.split(":"); String[] parts=address.split(":");
String result="200 OK";
try try
{ {
toserver = new Socket(parts[0],Integer.parseInt(parts[1])); 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) catch(IOException e)
{ {
result="503 Unavailable";
}
out.write(( out.write((
"HTTP/1.1 "+result+"\r\n"+ "HTTP/1.1 503 Unavailable\r\n"+
"Server: fake\r\n"+ "Server: fake\r\n"+
"Content-Length: 0\r\n"+ // TODO test fails without this! "Content-Length: 0\r\n"+
"\r\n" "\r\n"
).getBytes()); ).getBytes());
}
out.flush(); out.flush();
System.err.println(toserver); System.err.println(toserver);