Merged branch 'master' into 'jetty-9.1'.
This commit is contained in:
commit
8c2be70330
|
@ -129,7 +129,8 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
||||||
if (exchange == null)
|
if (exchange == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
parser.setHeadResponse(HttpMethod.HEAD.is(exchange.getRequest().getMethod()));
|
String method = exchange.getRequest().getMethod();
|
||||||
|
parser.setHeadResponse(HttpMethod.HEAD.is(method) || HttpMethod.CONNECT.is(method));
|
||||||
exchange.getResponse().version(version).status(status).reason(reason);
|
exchange.getResponse().version(version).status(status).reason(reason);
|
||||||
|
|
||||||
responseBegin(exchange);
|
responseBegin(exchange);
|
||||||
|
@ -177,7 +178,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
responseSuccess(exchange);
|
responseSuccess(exchange);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.proxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
|
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.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -55,6 +56,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -116,14 +118,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
|
||||||
|
@ -364,6 +372,42 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
SslContextFactory sslContextFactory = new SslContextFactory();
|
||||||
|
sslContextFactory.start();
|
||||||
|
|
||||||
|
HttpClient httpClient = new HttpClient(sslContextFactory);
|
||||||
|
httpClient.setProxyConfiguration(new ProxyConfiguration(proxyHost, proxyPort));
|
||||||
|
httpClient.start();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ContentResponse response = httpClient.newRequest("https://www.google.com")
|
||||||
|
// Use a longer timeout, sometimes the proxy takes a while to answer
|
||||||
|
.timeout(20, TimeUnit.SECONDS)
|
||||||
|
.send();
|
||||||
|
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||||
|
}
|
||||||
|
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