Merge branch 'jetty-8' into release-8
This commit is contained in:
commit
5a0f8f8e4d
|
@ -36,7 +36,6 @@ import org.eclipse.jetty.http.HttpVersions;
|
||||||
import org.eclipse.jetty.io.AbstractConnection;
|
import org.eclipse.jetty.io.AbstractConnection;
|
||||||
import org.eclipse.jetty.io.Buffer;
|
import org.eclipse.jetty.io.Buffer;
|
||||||
import org.eclipse.jetty.io.Buffers;
|
import org.eclipse.jetty.io.Buffers;
|
||||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
|
||||||
import org.eclipse.jetty.io.Connection;
|
import org.eclipse.jetty.io.Connection;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.io.EofException;
|
import org.eclipse.jetty.io.EofException;
|
||||||
|
@ -318,7 +317,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
{
|
{
|
||||||
HttpExchange exchange = _exchange;
|
HttpExchange exchange = _exchange;
|
||||||
if (exchange!=null)
|
if (exchange!=null)
|
||||||
|
{
|
||||||
exchange.setStatus(HttpExchange.STATUS_PARSING_CONTENT);
|
exchange.setStatus(HttpExchange.STATUS_PARSING_CONTENT);
|
||||||
|
if (HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod()))
|
||||||
|
_parser.setPersistent(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -350,8 +353,6 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -68,8 +68,17 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest
|
||||||
|
|
||||||
protected void stopProxy() throws Exception
|
protected void stopProxy() throws Exception
|
||||||
{
|
{
|
||||||
_proxySocket.close();
|
if (_proxySocket != null)
|
||||||
_proxyThread.interrupt();
|
{
|
||||||
|
_proxySocket.close();
|
||||||
|
_proxyThread.interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testExternalProxy() throws Exception
|
||||||
|
{
|
||||||
|
// Do not execute this test, since it won't hit the fake proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
static class FakeProxy extends Thread
|
static class FakeProxy extends Thread
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
|
import java.net.Socket;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -46,6 +47,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -106,14 +108,20 @@ public class ProxyTunnellingTest
|
||||||
|
|
||||||
protected void stopServer() throws Exception
|
protected void stopServer() throws Exception
|
||||||
{
|
{
|
||||||
server.stop();
|
if (server != null)
|
||||||
server.join();
|
{
|
||||||
|
server.stop();
|
||||||
|
server.join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void stopProxy() throws Exception
|
protected void stopProxy() throws Exception
|
||||||
{
|
{
|
||||||
proxy.stop();
|
if (proxy != null)
|
||||||
proxy.join();
|
{
|
||||||
|
proxy.stop();
|
||||||
|
proxy.join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -337,6 +345,51 @@ public class ProxyTunnellingTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExternalProxy() throws Exception
|
||||||
|
{
|
||||||
|
// Free proxy server obtained from http://hidemyass.com/proxy-list/
|
||||||
|
String proxyHost = "81.208.25.53";
|
||||||
|
int proxyPort = 3128;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new Socket(proxyHost, proxyPort).close();
|
||||||
|
}
|
||||||
|
catch (IOException x)
|
||||||
|
{
|
||||||
|
Assume.assumeNoException(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the server to start the SslContextFactory
|
||||||
|
startSSLServer(new AbstractHandler()
|
||||||
|
{
|
||||||
|
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
|
{
|
||||||
|
throw new ServletException();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
httpClient.setProxy(new Address(proxyHost, proxyPort));
|
||||||
|
httpClient.registerListener(RedirectListener.class.getName());
|
||||||
|
httpClient.start();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ContentExchange exchange = new ContentExchange(true);
|
||||||
|
// Use a longer timeout, sometimes the proxy takes a while to answer
|
||||||
|
exchange.setTimeout(20000);
|
||||||
|
exchange.setURL("https://www.google.com");
|
||||||
|
httpClient.send(exchange);
|
||||||
|
assertEquals(HttpExchange.STATUS_COMPLETED, exchange.waitForDone());
|
||||||
|
assertEquals(200, exchange.getResponseStatus());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
httpClient.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class ServerHandler extends AbstractHandler
|
private static class ServerHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
|
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
|
||||||
|
|
Loading…
Reference in New Issue