Fixes #659 - CONNECT request fails spuriously.
Fixed by properly returning true from messageComplete() in case of a 101 response or a 200 CONNECT response.
This commit is contained in:
parent
a07461f4bd
commit
72393bc666
|
@ -206,6 +206,9 @@ public class HttpProxy extends ProxyConfiguration.Proxy
|
||||||
new SslClientConnectionFactory(client.getSslContextFactory(), client.getByteBufferPool(), client.getExecutor(), connectionFactory);
|
new SslClientConnectionFactory(client.getSslContextFactory(), client.getByteBufferPool(), client.getExecutor(), connectionFactory);
|
||||||
HttpConnectionOverHTTP oldConnection = (HttpConnectionOverHTTP)endPoint.getConnection();
|
HttpConnectionOverHTTP oldConnection = (HttpConnectionOverHTTP)endPoint.getConnection();
|
||||||
org.eclipse.jetty.io.Connection newConnection = sslConnectionFactory.newConnection(endPoint, context);
|
org.eclipse.jetty.io.Connection newConnection = sslConnectionFactory.newConnection(endPoint, context);
|
||||||
|
// Creating the connection will link the new Connection the EndPoint,
|
||||||
|
// but we need the old Connection linked for the upgrade to do its job.
|
||||||
|
endPoint.setConnection(oldConnection);
|
||||||
endPoint.upgrade(newConnection);
|
endPoint.upgrade(newConnection);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("HTTP tunnel established: {} over {}", oldConnection, newConnection);
|
LOG.debug("HTTP tunnel established: {} over {}", oldConnection, newConnection);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.jetty.client.HttpResponseException;
|
||||||
import org.eclipse.jetty.http.HttpField;
|
import org.eclipse.jetty.http.HttpField;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
import org.eclipse.jetty.http.HttpParser;
|
import org.eclipse.jetty.http.HttpParser;
|
||||||
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.http.HttpVersion;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
|
@ -265,7 +266,19 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
||||||
if (exchange == null)
|
if (exchange == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !responseSuccess(exchange);
|
boolean proceed = responseSuccess(exchange);
|
||||||
|
if (!proceed)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int status = exchange.getResponse().getStatus();
|
||||||
|
if (status == HttpStatus.SWITCHING_PROTOCOLS_101)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (HttpMethod.CONNECT.is(exchange.getRequest().getMethod()) &&
|
||||||
|
status == HttpStatus.OK_200)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -77,6 +77,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
import org.eclipse.jetty.http.HttpVersion;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
|
import org.eclipse.jetty.io.AbstractConnection;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||||
|
@ -1509,6 +1510,11 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
||||||
ContentResponse response = listener.get(5, TimeUnit.SECONDS);
|
ContentResponse response = listener.get(5, TimeUnit.SECONDS);
|
||||||
Assert.assertEquals(200, response.getStatus());
|
Assert.assertEquals(200, response.getStatus());
|
||||||
|
|
||||||
|
// Because the tunnel was successful, this connection will be
|
||||||
|
// upgraded to an SslConnection, so it will not be fill interested.
|
||||||
|
// This test doesn't upgrade, so it needs to restore the fill interest.
|
||||||
|
((AbstractConnection)connection).fillInterested();
|
||||||
|
|
||||||
// Test that I can send another request on the same connection.
|
// Test that I can send another request on the same connection.
|
||||||
request = client.newRequest(host, port);
|
request = client.newRequest(host, port);
|
||||||
listener = new FutureResponseListener(request);
|
listener = new FutureResponseListener(request);
|
||||||
|
|
Loading…
Reference in New Issue