Refactored SPDY modules and added ALPN tests.
This commit is contained in:
parent
addc49f391
commit
2f22a1066c
|
@ -20,7 +20,7 @@
|
|||
<module>spdy-http-common</module>
|
||||
<module>spdy-http-server</module>
|
||||
<module>spdy-http-client-transport</module>
|
||||
<module>spdy-npn-tests</module>
|
||||
<module>spdy-alpn-tests</module>
|
||||
<module>spdy-example-webapp</module>
|
||||
</modules>
|
||||
|
||||
|
@ -71,4 +71,16 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jdk7-npn</id>
|
||||
<activation>
|
||||
<jdk>[1.7,1.8)</jdk>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>spdy-npn-tests</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.spdy</groupId>
|
||||
<artifactId>spdy-parent</artifactId>
|
||||
<version>9.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spdy-alpn-tests</artifactId>
|
||||
<name>Jetty :: SPDY :: ALPN Tests</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.mortbay.jetty.alpn</groupId>
|
||||
<artifactId>alpn-boot</artifactId>
|
||||
<version>${alpn.version}</version>
|
||||
<type>jar</type>
|
||||
<overWrite>false</overWrite>
|
||||
<outputDirectory>${project.build.directory}/alpn</outputDirectory>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>-Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.alpn</groupId>
|
||||
<artifactId>alpn-api</artifactId>
|
||||
<version>${alpn.api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.spdy</groupId>
|
||||
<artifactId>spdy-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.spdy</groupId>
|
||||
<artifactId>spdy-http-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.spdy</groupId>
|
||||
<artifactId>spdy-http-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,216 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.spdy.server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
import org.eclipse.jetty.alpn.ALPN;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ALPNNegotiationTest extends AbstractALPNTest
|
||||
{
|
||||
@Test
|
||||
public void testClientAdvertisingHTTPServerSpeaksHTTP() throws Exception
|
||||
{
|
||||
InetSocketAddress address = prepare();
|
||||
connector.addConnectionFactory(new HttpConnectionFactory());
|
||||
|
||||
SslContextFactory sslContextFactory = newSslContextFactory();
|
||||
sslContextFactory.start();
|
||||
SSLContext sslContext = sslContextFactory.getSslContext();
|
||||
|
||||
try (SSLSocket client = (SSLSocket)sslContext.getSocketFactory().createSocket(address.getAddress(), address.getPort()))
|
||||
{
|
||||
client.setUseClientMode(true);
|
||||
client.setSoTimeout(5000);
|
||||
|
||||
ALPN.put(client, new ALPN.ClientProvider()
|
||||
{
|
||||
@Override
|
||||
public boolean supports()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsupported()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> protocols()
|
||||
{
|
||||
return Arrays.asList("http/1.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(String protocol)
|
||||
{
|
||||
Assert.assertEquals("http/1.1", protocol);
|
||||
}
|
||||
});
|
||||
|
||||
client.startHandshake();
|
||||
|
||||
// Verify that the server really speaks http/1.1
|
||||
|
||||
OutputStream output = client.getOutputStream();
|
||||
output.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + address.getPort() + "\r\n" +
|
||||
"\r\n" +
|
||||
"").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
InputStream input = client.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertTrue(line.contains(" 404 "));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientAdvertisingMultipleProtocolsServerSpeaksHTTPWhenNegotiated() throws Exception
|
||||
{
|
||||
InetSocketAddress address = prepare();
|
||||
connector.addConnectionFactory(new HttpConnectionFactory());
|
||||
|
||||
SslContextFactory sslContextFactory = newSslContextFactory();
|
||||
sslContextFactory.start();
|
||||
SSLContext sslContext = sslContextFactory.getSslContext();
|
||||
try (SSLSocket client = (SSLSocket)sslContext.getSocketFactory().createSocket(address.getAddress(), address.getPort()))
|
||||
{
|
||||
client.setUseClientMode(true);
|
||||
client.setSoTimeout(5000);
|
||||
|
||||
ALPN.put(client, new ALPN.ClientProvider()
|
||||
{
|
||||
@Override
|
||||
public boolean supports()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsupported()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> protocols()
|
||||
{
|
||||
return Arrays.asList("unknown/1.0", "http/1.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(String protocol)
|
||||
{
|
||||
Assert.assertEquals("http/1.1", protocol);
|
||||
}
|
||||
});
|
||||
|
||||
client.startHandshake();
|
||||
|
||||
// Verify that the server really speaks http/1.1
|
||||
|
||||
OutputStream output = client.getOutputStream();
|
||||
output.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + address.getPort() + "\r\n" +
|
||||
"\r\n" +
|
||||
"").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
InputStream input = client.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertTrue(line.contains(" 404 "));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientNotSupportingALPNServerSpeaksDefaultProtocol() throws Exception
|
||||
{
|
||||
InetSocketAddress address = prepare();
|
||||
connector.addConnectionFactory(new HttpConnectionFactory());
|
||||
|
||||
SslContextFactory sslContextFactory = newSslContextFactory();
|
||||
sslContextFactory.start();
|
||||
SSLContext sslContext = sslContextFactory.getSslContext();
|
||||
try (SSLSocket client = (SSLSocket)sslContext.getSocketFactory().createSocket(address.getAddress(), address.getPort()))
|
||||
{
|
||||
client.setUseClientMode(true);
|
||||
client.setSoTimeout(5000);
|
||||
|
||||
ALPN.put(client, new ALPN.ClientProvider()
|
||||
{
|
||||
@Override
|
||||
public boolean supports()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsupported()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> protocols()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(String s)
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
client.startHandshake();
|
||||
|
||||
// Verify that the server really speaks http/1.1
|
||||
|
||||
OutputStream output = client.getOutputStream();
|
||||
output.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + address.getPort() + "\r\n" +
|
||||
"\r\n" +
|
||||
"").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
InputStream input = client.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertTrue(line.contains(" 404 "));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.spdy.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.List;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.alpn.ALPN;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ALPNSynReplyTest extends AbstractALPNTest
|
||||
{
|
||||
@Test
|
||||
public void testGentleCloseDuringHandshake() throws Exception
|
||||
{
|
||||
InetSocketAddress address = prepare();
|
||||
SslContextFactory sslContextFactory = newSslContextFactory();
|
||||
sslContextFactory.start();
|
||||
SSLEngine sslEngine = sslContextFactory.newSSLEngine(address);
|
||||
sslEngine.setUseClientMode(true);
|
||||
ALPN.put(sslEngine, new ALPN.ClientProvider()
|
||||
{
|
||||
@Override
|
||||
public boolean supports()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsupported()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> protocols()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(String protocol)
|
||||
{
|
||||
}
|
||||
});
|
||||
sslEngine.beginHandshake();
|
||||
|
||||
ByteBuffer encrypted = ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize());
|
||||
sslEngine.wrap(BufferUtil.EMPTY_BUFFER, encrypted);
|
||||
encrypted.flip();
|
||||
|
||||
try (SocketChannel channel = SocketChannel.open(address))
|
||||
{
|
||||
// Send ClientHello, immediately followed by TLS Close Alert and then by FIN
|
||||
channel.write(encrypted);
|
||||
sslEngine.closeOutbound();
|
||||
encrypted.clear();
|
||||
sslEngine.wrap(BufferUtil.EMPTY_BUFFER, encrypted);
|
||||
encrypted.flip();
|
||||
channel.write(encrypted);
|
||||
channel.shutdownOutput();
|
||||
|
||||
// Read ServerHello from server
|
||||
encrypted.clear();
|
||||
int read = channel.read(encrypted);
|
||||
encrypted.flip();
|
||||
Assert.assertTrue(read > 0);
|
||||
// Cannot decrypt, as the SSLEngine has been already closed
|
||||
|
||||
// Now if we read more, we should either read the TLS Close Alert, or directly -1
|
||||
encrypted.clear();
|
||||
read = channel.read(encrypted);
|
||||
// Sending a TLS Close Alert during handshake results in an exception when
|
||||
// unwrapping that the server react to by closing the connection abruptly.
|
||||
Assert.assertTrue(read < 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbruptCloseDuringHandshake() throws Exception
|
||||
{
|
||||
InetSocketAddress address = prepare();
|
||||
SslContextFactory sslContextFactory = newSslContextFactory();
|
||||
sslContextFactory.start();
|
||||
SSLEngine sslEngine = sslContextFactory.newSSLEngine(address);
|
||||
sslEngine.setUseClientMode(true);
|
||||
ALPN.put(sslEngine, new ALPN.ClientProvider()
|
||||
{
|
||||
@Override
|
||||
public boolean supports()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsupported()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> protocols()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(String s)
|
||||
{
|
||||
}
|
||||
});
|
||||
sslEngine.beginHandshake();
|
||||
|
||||
ByteBuffer encrypted = ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize());
|
||||
sslEngine.wrap(BufferUtil.EMPTY_BUFFER, encrypted);
|
||||
encrypted.flip();
|
||||
|
||||
try (SocketChannel channel = SocketChannel.open(address))
|
||||
{
|
||||
// Send ClientHello, immediately followed by FIN (no TLS Close Alert)
|
||||
channel.write(encrypted);
|
||||
channel.shutdownOutput();
|
||||
|
||||
// Read ServerHello from server
|
||||
encrypted.clear();
|
||||
int read = channel.read(encrypted);
|
||||
encrypted.flip();
|
||||
Assert.assertTrue(read > 0);
|
||||
ByteBuffer decrypted = ByteBuffer.allocate(sslEngine.getSession().getApplicationBufferSize());
|
||||
sslEngine.unwrap(encrypted, decrypted);
|
||||
|
||||
// Now if we read more, we should either read the TLS Close Alert, or directly -1
|
||||
encrypted.clear();
|
||||
read = channel.read(encrypted);
|
||||
// Since we have close the connection abruptly, the server also does so
|
||||
Assert.assertTrue(read < 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.spdy.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.eclipse.jetty.alpn.ALPN;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.spdy.client.SPDYClient;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
|
||||
public class AbstractALPNTest
|
||||
{
|
||||
@Rule
|
||||
public final TestTracker tracker = new TestTracker();
|
||||
protected Server server;
|
||||
protected SPDYServerConnector connector;
|
||||
protected SPDYClient.Factory clientFactory;
|
||||
|
||||
protected InetSocketAddress prepare() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SPDYServerConnector(server, newSslContextFactory(), null, new ALPNServerConnectionFactory("spdy/3", "spdy/2", "http/1.1"));
|
||||
connector.setPort(0);
|
||||
connector.setIdleTimeout(30000);
|
||||
server.addConnector(connector);
|
||||
server.start();
|
||||
|
||||
QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
threadPool.setName(threadPool.getName() + "-client");
|
||||
clientFactory = new SPDYClient.Factory(threadPool);
|
||||
clientFactory.start();
|
||||
|
||||
ALPN.debug = true;
|
||||
|
||||
return new InetSocketAddress("localhost", connector.getLocalPort());
|
||||
}
|
||||
|
||||
protected SslContextFactory newSslContextFactory()
|
||||
{
|
||||
SslContextFactory sslContextFactory = new SslContextFactory();
|
||||
sslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
|
||||
sslContextFactory.setKeyStorePassword("storepwd");
|
||||
sslContextFactory.setTrustStorePath("src/test/resources/truststore.jks");
|
||||
sslContextFactory.setTrustStorePassword("storepwd");
|
||||
sslContextFactory.setProtocol("TLSv1");
|
||||
sslContextFactory.setIncludeProtocols("TLSv1");
|
||||
return sslContextFactory;
|
||||
}
|
||||
|
||||
@After
|
||||
public void dispose() throws Exception
|
||||
{
|
||||
clientFactory.stop();
|
||||
server.stop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
#org.eclipse.jetty.spdy.LEVEL=DEBUG
|
Binary file not shown.
Binary file not shown.
|
@ -19,12 +19,14 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.server.NPNServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.server.NegotiatingServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.server.SPDYServerConnectionFactory;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
|
@ -37,7 +39,7 @@ public class HTTPSPDYProxyServerConnector extends ServerConnector
|
|||
|
||||
public HTTPSPDYProxyServerConnector(Server server, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector)
|
||||
{
|
||||
this(server, null, config, proxyEngineSelector);
|
||||
super(server, (SslContextFactory)null, new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector));
|
||||
}
|
||||
|
||||
public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, ProxyEngineSelector proxyEngineSelector)
|
||||
|
@ -47,16 +49,15 @@ public class HTTPSPDYProxyServerConnector extends ServerConnector
|
|||
|
||||
public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector)
|
||||
{
|
||||
super(server,
|
||||
sslContextFactory,
|
||||
sslContextFactory == null
|
||||
? new ConnectionFactory[]{new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector)}
|
||||
: new ConnectionFactory[]{new NPNServerConnectionFactory("spdy/3", "spdy/2", "http/1.1"),
|
||||
new SPDYServerConnectionFactory(SPDY.V3, proxyEngineSelector),
|
||||
new SPDYServerConnectionFactory(SPDY.V2, proxyEngineSelector),
|
||||
new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector)});
|
||||
NPNServerConnectionFactory npnConnectionFactory = getConnectionFactory(NPNServerConnectionFactory.class);
|
||||
if (npnConnectionFactory != null)
|
||||
npnConnectionFactory.setDefaultProtocol("http/1.1");
|
||||
this(server, sslContextFactory, config, proxyEngineSelector, new NPNServerConnectionFactory("spdy/3", "spdy/2", "http/1.1"));
|
||||
}
|
||||
|
||||
public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector, NegotiatingServerConnectionFactory negotiatingFactory)
|
||||
{
|
||||
super(server, Objects.requireNonNull(sslContextFactory), negotiatingFactory,
|
||||
new SPDYServerConnectionFactory(SPDY.V3, proxyEngineSelector),
|
||||
new SPDYServerConnectionFactory(SPDY.V2, proxyEngineSelector),
|
||||
new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector));
|
||||
negotiatingFactory.setDefaultProtocol("http/1.1");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,18 +50,15 @@ import org.eclipse.jetty.spdy.client.SPDYClient;
|
|||
import org.eclipse.jetty.spdy.http.HTTPSPDYHeader;
|
||||
import org.eclipse.jetty.spdy.server.SPDYServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.server.SPDYServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -69,33 +66,19 @@ import static org.hamcrest.CoreMatchers.is;
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public abstract class ProxyHTTPToSPDYTest
|
||||
public class ProxyHTTPToSPDYTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ProxyHTTPToSPDYTest.class);
|
||||
@Rule
|
||||
public final TestWatcher testName = new TestWatcher()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void starting(Description description)
|
||||
{
|
||||
super.starting(description);
|
||||
System.err.printf("Running %s.%s()%n",
|
||||
description.getClassName(),
|
||||
description.getMethodName());
|
||||
}
|
||||
};
|
||||
|
||||
private final short version;
|
||||
private HttpClient httpClient;
|
||||
private HttpClient httpClient2;
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Short[]> parameters()
|
||||
{
|
||||
return Arrays.asList(new Short[]{SPDY.V2}, new Short[]{SPDY.V3});
|
||||
}
|
||||
|
||||
@Rule
|
||||
public final TestTracker tracker = new TestTracker();
|
||||
private final short version;
|
||||
private HttpClient httpClient;
|
||||
private HttpClient httpClient2;
|
||||
private SPDYClient.Factory factory;
|
||||
private Server server;
|
||||
private Server proxy;
|
||||
|
|
|
@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
|
@ -52,7 +53,9 @@ import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
|||
import org.eclipse.jetty.spdy.api.StringDataInfo;
|
||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
import org.eclipse.jetty.spdy.client.SPDYClient;
|
||||
import org.eclipse.jetty.spdy.server.NegotiatingServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.server.http.SPDYTestUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
@ -65,8 +68,6 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -80,23 +81,6 @@ import static org.junit.Assert.assertThat;
|
|||
public abstract class ProxySPDYToHTTPLoadTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ProxySPDYToHTTPLoadTest.class);
|
||||
@Rule
|
||||
public final TestWatcher testName = new TestWatcher()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void starting(Description description)
|
||||
{
|
||||
super.starting(description);
|
||||
System.err.printf("Running %s.%s()%n",
|
||||
description.getClassName(),
|
||||
description.getMethodName());
|
||||
}
|
||||
};
|
||||
|
||||
private final short version;
|
||||
private final String server1String = "server1";
|
||||
private final String server2String = "server2";
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Short[]> parameters()
|
||||
|
@ -104,6 +88,12 @@ public abstract class ProxySPDYToHTTPLoadTest
|
|||
return Arrays.asList(new Short[]{SPDY.V2}, new Short[]{SPDY.V3});
|
||||
}
|
||||
|
||||
@Rule
|
||||
public final TestTracker tracker = new TestTracker();
|
||||
private final short version;
|
||||
private final NegotiatingServerConnectionFactory negotiator;
|
||||
private final String server1String = "server1";
|
||||
private final String server2String = "server2";
|
||||
private SPDYClient.Factory factory;
|
||||
private Server server1;
|
||||
private Server server2;
|
||||
|
@ -111,9 +101,10 @@ public abstract class ProxySPDYToHTTPLoadTest
|
|||
private ServerConnector proxyConnector;
|
||||
private SslContextFactory sslContextFactory = SPDYTestUtils.newSslContextFactory();
|
||||
|
||||
public ProxySPDYToHTTPLoadTest(short version)
|
||||
public ProxySPDYToHTTPLoadTest(short version, NegotiatingServerConnectionFactory negotiator)
|
||||
{
|
||||
this.version = version;
|
||||
this.negotiator = negotiator;
|
||||
}
|
||||
|
||||
@Before
|
||||
|
@ -187,7 +178,7 @@ public abstract class ProxySPDYToHTTPLoadTest
|
|||
proxyEngineSelector.putProxyServerInfo("127.0.0.2", new ProxyEngineSelector.ProxyServerInfo("http/1.1",
|
||||
server2.getHostName(), server2.getPort()));
|
||||
|
||||
proxyConnector = new HTTPSPDYProxyServerConnector(proxy, sslContextFactory, proxyEngineSelector);
|
||||
proxyConnector = new HTTPSPDYProxyServerConnector(proxy, sslContextFactory, new HttpConfiguration(), proxyEngineSelector, negotiator);
|
||||
proxyConnector.setPort(0);
|
||||
proxyConnector.setIdleTimeout(proxyConnectorTimeout);
|
||||
proxy.addConnector(proxyConnector);
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
|
|||
import org.eclipse.jetty.spdy.client.SPDYClient;
|
||||
import org.eclipse.jetty.spdy.http.HTTPSPDYHeader;
|
||||
import org.eclipse.jetty.spdy.server.http.SPDYTestUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -65,8 +66,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -79,19 +78,7 @@ import static org.junit.Assert.assertThat;
|
|||
public abstract class ProxySPDYToHTTPTest
|
||||
{
|
||||
@Rule
|
||||
public final TestWatcher testName = new TestWatcher()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void starting(Description description)
|
||||
{
|
||||
super.starting(description);
|
||||
System.err.printf("Running %s.%s()%n",
|
||||
description.getClassName(),
|
||||
description.getMethodName());
|
||||
}
|
||||
};
|
||||
|
||||
public final TestTracker tracker = new TestTracker();
|
||||
private final short version;
|
||||
|
||||
@Parameterized.Parameters
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.jetty.spdy.client.SPDYClient;
|
|||
import org.eclipse.jetty.spdy.server.SPDYServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.server.SPDYServerConnector;
|
||||
import org.eclipse.jetty.spdy.server.http.SPDYTestUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
@ -56,8 +57,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -69,19 +68,7 @@ import static org.junit.Assert.assertThat;
|
|||
public abstract class ProxySPDYToSPDYLoadTest
|
||||
{
|
||||
@Rule
|
||||
public final TestWatcher testName = new TestWatcher()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void starting(Description description)
|
||||
{
|
||||
super.starting(description);
|
||||
System.err.printf("Running %s.%s()%n",
|
||||
description.getClassName(),
|
||||
description.getMethodName());
|
||||
}
|
||||
};
|
||||
|
||||
public final TestTracker tracker = new TestTracker();
|
||||
private final short version;
|
||||
|
||||
@Parameterized.Parameters
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.eclipse.jetty.spdy.http.HTTPSPDYHeader;
|
|||
import org.eclipse.jetty.spdy.server.SPDYServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.server.SPDYServerConnector;
|
||||
import org.eclipse.jetty.spdy.server.http.SPDYTestUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
|
@ -58,8 +59,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -70,18 +69,7 @@ import static org.junit.Assert.assertThat;
|
|||
public abstract class ProxySPDYToSPDYTest
|
||||
{
|
||||
@Rule
|
||||
public final TestWatcher testName = new TestWatcher()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void starting(Description description)
|
||||
{
|
||||
super.starting(description);
|
||||
System.err.printf("Running %s.%s()%n",
|
||||
description.getClassName(),
|
||||
description.getMethodName());
|
||||
}
|
||||
};
|
||||
public final TestTracker tracker = new TestTracker();
|
||||
private final short version;
|
||||
|
||||
@Parameterized.Parameters
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ProtocolNegotiationTest extends AbstractNPNTest
|
||||
public class NPNNegotiationTest extends AbstractNPNTest
|
||||
{
|
||||
@Test
|
||||
public void testServerAdvertisingHTTPSpeaksHTTP() throws Exception
|
|
@ -1,27 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
public class NPNProxyHTTPToSPDYTest extends ProxyHTTPToSPDYTest
|
||||
{
|
||||
public NPNProxyHTTPToSPDYTest(short version)
|
||||
{
|
||||
super(version);
|
||||
}
|
||||
}
|
|
@ -18,10 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import org.eclipse.jetty.spdy.server.NPNServerConnectionFactory;
|
||||
|
||||
public class NPNProxySPDYToHTTPLoadTest extends ProxySPDYToHTTPLoadTest
|
||||
{
|
||||
public NPNProxySPDYToHTTPLoadTest(short version)
|
||||
{
|
||||
super(version);
|
||||
super(version, new NPNServerConnectionFactory("spdy/3", "spdy/2", "http/1.1"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue