Implemented SPDY/3 HTTP layering.

This commit is contained in:
Simone Bordet 2012-06-01 19:29:07 +02:00
parent f872676a65
commit 6ff1a5fddc
8 changed files with 319 additions and 191 deletions

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.jetty.spdy.http;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jetty.spdy.api.SPDY;
public enum HTTPSPDYHeader
{
METHOD("method", ":method"),
URI("url", ":path"),
VERSION("version", ":version"),
SCHEME("scheme", ":scheme"),
HOST("host", ":host"),
STATUS("status", ":status");
public static HTTPSPDYHeader from(short version, String name)
{
switch (version)
{
case SPDY.V2:
return Names.v2Names.get(name);
case SPDY.V3:
return Names.v3Names.get(name);
default:
throw new IllegalStateException();
}
}
private final String v2Name;
private final String v3Name;
private HTTPSPDYHeader(String v2Name, String v3Name)
{
this.v2Name = v2Name;
Names.v2Names.put(v2Name, this);
this.v3Name = v3Name;
Names.v3Names.put(v3Name, this);
}
public String name(short version)
{
switch (version)
{
case SPDY.V2:
return v2Name;
case SPDY.V3:
return v3Name;
default:
throw new IllegalStateException();
}
}
private static class Names
{
private static final Map<String, HTTPSPDYHeader> v2Names = new HashMap<>();
private static final Map<String, HTTPSPDYHeader> v3Names = new HashMap<>();
}
}

View File

@ -66,6 +66,7 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
private final Queue<Runnable> tasks = new LinkedList<>();
private final BlockingQueue<DataInfo> dataInfos = new LinkedBlockingQueue<>();
private final short version;
private final SPDYAsyncConnection connection;
private final PushStrategy pushStrategy;
private final Stream stream;
@ -75,9 +76,10 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
private volatile State state = State.INITIAL;
private boolean dispatched; // Guarded by synchronization on tasks
public ServerHTTPSPDYAsyncConnection(Connector connector, AsyncEndPoint endPoint, Server server, SPDYAsyncConnection connection, PushStrategy pushStrategy, Stream stream)
public ServerHTTPSPDYAsyncConnection(Connector connector, AsyncEndPoint endPoint, Server server, short version, SPDYAsyncConnection connection, PushStrategy pushStrategy, Stream stream)
{
super(connector, endPoint, server);
this.version = version;
this.connection = connection;
this.pushStrategy = pushStrategy;
this.stream = stream;
@ -159,9 +161,9 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
}
case REQUEST:
{
Headers.Header method = headers.get("method");
Headers.Header uri = headers.get("url");
Headers.Header version = headers.get("version");
Headers.Header method = headers.get(HTTPSPDYHeader.METHOD.name(version));
Headers.Header uri = headers.get(HTTPSPDYHeader.URI.name(version));
Headers.Header version = headers.get(HTTPSPDYHeader.VERSION.name(this.version));
if (method == null || uri == null || version == null)
throw new HttpException(HttpStatus.BAD_REQUEST_400);
@ -181,15 +183,19 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
for (Headers.Header header : headers)
{
String name = header.name();
// Skip special SPDY headers, unless it's the "host" header
HTTPSPDYHeader specialHeader = HTTPSPDYHeader.from(version, name);
if (specialHeader != null)
{
if (specialHeader == HTTPSPDYHeader.HOST)
name = "host";
else
continue;
}
switch (name)
{
case "method":
case "version":
case "url":
{
// Skip request line headers
continue;
}
case "connection":
case "keep-alive":
case "proxy-connection":
@ -264,8 +270,8 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
else
{
Headers headers = new Headers();
headers.put("status", String.valueOf(status));
headers.put("version", "HTTP/1.1");
headers.put(HTTPSPDYHeader.STATUS.name(version), String.valueOf(status));
headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1");
stream.reply(new ReplyInfo(headers, true));
}
}
@ -393,21 +399,22 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
{
if (!stream.isUnidirectional())
stream.reply(replyInfo);
if (replyInfo.getHeaders().get("status").value().startsWith("200") && !stream.isClosed() && !isIfModifiedSinceHeaderPresent())
if (replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).value().startsWith("200") &&
!stream.isClosed() && !isIfModifiedSinceHeaderPresent())
{
// We have a 200 OK with some content to send
Headers.Header scheme = headers.get("scheme");
Headers.Header host = headers.get("host");
Headers.Header url = headers.get("url");
Set<String> pushResources = pushStrategy.apply(stream, this.headers, replyInfo.getHeaders());
String referrer = new StringBuilder(scheme.value()).append("://").append(host.value()).append(url.value()).toString();
Headers.Header scheme = headers.get(HTTPSPDYHeader.SCHEME.name(version));
Headers.Header host = headers.get(HTTPSPDYHeader.HOST.name(version));
Headers.Header uri = headers.get(HTTPSPDYHeader.URI.name(version));
Set<String> pushResources = pushStrategy.apply(stream, headers, replyInfo.getHeaders());
String referrer = new StringBuilder(scheme.value()).append("://").append(host.value()).append(uri.value()).toString();
for (String pushURL : pushResources)
{
final Headers pushHeaders = new Headers();
pushHeaders.put("method", "GET");
pushHeaders.put("url", pushURL);
pushHeaders.put("version", "HTTP/1.1");
pushHeaders.put(HTTPSPDYHeader.METHOD.name(version), "GET");
pushHeaders.put(HTTPSPDYHeader.URI.name(version), pushURL);
pushHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1");
pushHeaders.put(scheme);
pushHeaders.put(host);
pushHeaders.put("referer", referrer);
@ -418,7 +425,7 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
@Override
public void completed(Stream pushStream)
{
Synchronous pushConnection = new Synchronous(getConnector(), getEndPoint(), getServer(), connection, pushStrategy, pushStream);
Synchronous pushConnection = new Synchronous(getConnector(), getEndPoint(), getServer(), version, connection, pushStrategy, pushStream);
pushConnection.beginRequest(pushHeaders, true);
}
});
@ -427,12 +434,10 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
}
private boolean isIfModifiedSinceHeaderPresent()
{
if (headers.get("if-modified-since") != null)
return true;
return false;
}
{
return headers.get("if-modified-since") != null;
}
private Buffer consumeContent(long maxIdleTime) throws IOException, InterruptedException
{
while (true)
@ -614,11 +619,11 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
{
Headers headers = new Headers();
String version = "HTTP/1.1";
headers.put("version", version);
headers.put(HTTPSPDYHeader.VERSION.name(ServerHTTPSPDYAsyncConnection.this.version), version);
StringBuilder status = new StringBuilder().append(_status);
if (_reason != null)
status.append(" ").append(_reason.toString("UTF-8"));
headers.put("status", status.toString());
headers.put(HTTPSPDYHeader.STATUS.name(ServerHTTPSPDYAsyncConnection.this.version), status.toString());
logger.debug("HTTP < {} {}", version, status);
if (fields != null)
@ -747,9 +752,9 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
private static class Synchronous extends ServerHTTPSPDYAsyncConnection
{
private Synchronous(Connector connector, AsyncEndPoint endPoint, Server server, SPDYAsyncConnection connection, PushStrategy pushStrategy, Stream stream)
private Synchronous(Connector connector, AsyncEndPoint endPoint, Server server, short version, SPDYAsyncConnection connection, PushStrategy pushStrategy, Stream stream)
{
super(connector, endPoint, server, connection, pushStrategy, stream);
super(connector, endPoint, server, version, connection, pushStrategy, stream);
}
@Override

View File

@ -78,8 +78,8 @@ public class ServerHTTPSPDYAsyncConnectionFactory extends ServerSPDYAsyncConnect
logger.debug("Received {} on {}", synInfo, stream);
HTTPSPDYAsyncEndPoint asyncEndPoint = new HTTPSPDYAsyncEndPoint(endPoint, stream);
ServerHTTPSPDYAsyncConnection connection = new ServerHTTPSPDYAsyncConnection(connector,
asyncEndPoint, connector.getServer(), (SPDYAsyncConnection)endPoint.getConnection(),
ServerHTTPSPDYAsyncConnection connection = new ServerHTTPSPDYAsyncConnection(connector, asyncEndPoint,
connector.getServer(), getVersion(), (SPDYAsyncConnection)endPoint.getConnection(),
pushStrategy, stream);
asyncEndPoint.setConnection(connection);
stream.setAttribute(CONNECTION_ATTRIBUTE, connection);

View File

@ -54,9 +54,14 @@ public abstract class AbstractHTTPSPDYTest
protected SPDYServerConnector connector;
protected InetSocketAddress startHTTPServer(Handler handler) throws Exception
{
return startHTTPServer(SPDY.V2, handler);
}
protected InetSocketAddress startHTTPServer(short version, Handler handler) throws Exception
{
server = new Server();
connector = newHTTPSPDYServerConnector();
connector = newHTTPSPDYServerConnector(version);
connector.setPort(0);
server.addConnector(connector);
server.setHandler(handler);
@ -64,16 +69,21 @@ public abstract class AbstractHTTPSPDYTest
return new InetSocketAddress("localhost", connector.getLocalPort());
}
protected SPDYServerConnector newHTTPSPDYServerConnector()
protected SPDYServerConnector newHTTPSPDYServerConnector(short version)
{
// For these tests, we need the connector to speak HTTP over SPDY even in non-SSL
SPDYServerConnector connector = new HTTPSPDYServerConnector();
AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V2, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, new PushStrategy.None());
AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, new PushStrategy.None());
connector.setDefaultAsyncConnectionFactory(defaultFactory);
return connector;
}
protected Session startClient(InetSocketAddress socketAddress, SessionFrameListener listener) throws Exception
{
return startClient(SPDY.V2, socketAddress, listener);
}
protected Session startClient(short version, InetSocketAddress socketAddress, SessionFrameListener listener) throws Exception
{
if (clientFactory == null)
{
@ -82,7 +92,7 @@ public abstract class AbstractHTTPSPDYTest
clientFactory = newSPDYClientFactory(threadPool);
clientFactory.start();
}
return clientFactory.newSPDYClient(SPDY.V2).connect(socketAddress, listener).get(5, TimeUnit.SECONDS);
return clientFactory.newSPDYClient(version).connect(socketAddress, listener).get(5, TimeUnit.SECONDS);
}
protected SPDYClient.Factory newSPDYClientFactory(Executor threadPool)

View File

@ -16,7 +16,6 @@ import org.eclipse.jetty.spdy.SPDYServerConnector;
import org.eclipse.jetty.spdy.api.DataInfo;
import org.eclipse.jetty.spdy.api.Headers;
import org.eclipse.jetty.spdy.api.ReplyInfo;
import org.eclipse.jetty.spdy.api.SPDY;
import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.SessionFrameListener;
import org.eclipse.jetty.spdy.api.Stream;
@ -28,10 +27,10 @@ import org.junit.Test;
public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
{
@Override
protected SPDYServerConnector newHTTPSPDYServerConnector()
protected SPDYServerConnector newHTTPSPDYServerConnector(short version)
{
SPDYServerConnector connector = super.newHTTPSPDYServerConnector();
AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V2, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, new ReferrerPushStrategy());
SPDYServerConnector connector = super.newHTTPSPDYServerConnector(version);
AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, new ReferrerPushStrategy());
connector.setDefaultAsyncConnectionFactory(defaultFactory);
return connector;
}

View File

@ -40,6 +40,7 @@ import org.eclipse.jetty.spdy.api.BytesDataInfo;
import org.eclipse.jetty.spdy.api.DataInfo;
import org.eclipse.jetty.spdy.api.Headers;
import org.eclipse.jetty.spdy.api.ReplyInfo;
import org.eclipse.jetty.spdy.api.SPDY;
import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.Stream;
import org.eclipse.jetty.spdy.api.StreamFrameListener;
@ -48,14 +49,19 @@ import org.eclipse.jetty.spdy.api.SynInfo;
import org.junit.Assert;
import org.junit.Test;
public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
public class ServerHTTPSPDYv2Test extends AbstractHTTPSPDYTest
{
protected short version()
{
return SPDY.V2;
}
@Test
public void testSimpleGET() throws Exception
{
final String path = "/foo";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -71,11 +77,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", path);
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), path);
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
{
@ -84,7 +90,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
});
@ -99,7 +105,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String query = "p=1";
final String uri = path + "?" + query;
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -115,11 +121,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", uri);
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), uri);
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
{
@ -128,7 +134,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
});
@ -141,7 +147,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final String path = "/foo";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -156,11 +162,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "HEAD");
headers.put("url", path);
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "HEAD");
headers.put(HTTPSPDYHeader.URI.name(version()), path);
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
{
@ -169,7 +175,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
});
@ -183,7 +189,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String path = "/foo";
final String data = "a=1&b=2";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -206,11 +212,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "POST");
headers.put("url", path);
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "POST");
headers.put(HTTPSPDYHeader.URI.name(version()), path);
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
headers.put("content-type", "application/x-www-form-urlencoded");
final CountDownLatch replyLatch = new CountDownLatch(1);
Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter()
@ -220,7 +226,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
}).get(5, TimeUnit.SECONDS);
@ -237,7 +243,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String data1 = "a=1&";
final String data2 = "b=2";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -252,11 +258,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "POST");
headers.put("url", path);
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "POST");
headers.put(HTTPSPDYHeader.URI.name(version()), path);
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
headers.put("content-type", "application/x-www-form-urlencoded");
final CountDownLatch replyLatch = new CountDownLatch(1);
Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter()
@ -266,7 +272,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
}).get(5, TimeUnit.SECONDS);
@ -286,7 +292,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String data1 = "a=1&";
final String data2 = "b=2";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -301,11 +307,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "POST");
headers.put("url", path);
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "POST");
headers.put(HTTPSPDYHeader.URI.name(version()), path);
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
headers.put("content-type", "application/x-www-form-urlencoded");
final CountDownLatch replyLatch = new CountDownLatch(1);
Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter()
@ -315,7 +321,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.toString(), replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.toString(), replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
}).get(5, TimeUnit.SECONDS);
@ -332,7 +338,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final String data = "0123456789ABCDEF";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -347,11 +353,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -361,7 +367,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -383,7 +389,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final char data = 'x';
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -398,11 +404,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -412,7 +418,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -437,7 +443,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String data1 = "0123456789ABCDEF";
final String data2 = "FEDCBA9876543210";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -454,11 +460,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(2);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -472,7 +478,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
Assert.assertEquals(1, replyFrames.incrementAndGet());
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -499,7 +505,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final byte[] data = new byte[128 * 1024];
Arrays.fill(data, (byte)'x');
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -514,11 +520,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -530,7 +536,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -556,7 +562,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final byte[] data = new byte[128 * 1024];
Arrays.fill(data, (byte)'y');
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -572,11 +578,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -588,7 +594,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -613,7 +619,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final String data = "0123456789ABCDEF";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -630,11 +636,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -646,7 +652,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -674,7 +680,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String data1 = "0123456789ABCDEF";
final String data2 = "FEDCBA9876543210";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -693,11 +699,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -709,7 +715,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -736,7 +742,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final String suffix = "/redirect";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -751,11 +757,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
{
@ -767,7 +773,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
Assert.assertEquals(1, replies.incrementAndGet());
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("302"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("302"));
Assert.assertTrue(replyHeaders.get("location").value().endsWith(suffix));
replyLatch.countDown();
}
@ -780,7 +786,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
public void testGETWithSendError() throws Exception
{
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -793,11 +799,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -810,7 +816,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
Assert.assertEquals(1, replies.incrementAndGet());
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("404"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("404"));
replyLatch.countDown();
}
@ -829,7 +835,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
@Test
public void testGETWithException() throws Exception
{
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -840,11 +846,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
{
@ -856,7 +862,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
Assert.assertEquals(1, replies.incrementAndGet());
Assert.assertTrue(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("500"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("500"));
replyLatch.countDown();
}
});
@ -869,7 +875,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
final String pangram1 = "the quick brown fox jumps over the lazy dog";
final String pangram2 = "qualche vago ione tipo zolfo, bromo, sodio";
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -887,11 +893,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(2);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -905,7 +911,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
Assert.assertEquals(1, replyFrames.incrementAndGet());
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
Assert.assertTrue(replyHeaders.get("extra").value().contains("X"));
replyLatch.countDown();
}
@ -937,7 +943,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final byte[] data = new byte[2048];
final CountDownLatch handlerLatch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -953,11 +959,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "GET");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
final CountDownLatch dataLatch = new CountDownLatch(1);
session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
@ -971,7 +977,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
Assert.assertEquals(1, replyFrames.incrementAndGet());
Assert.assertFalse(replyInfo.isClose());
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
@ -994,7 +1000,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final byte[] data = new byte[2000];
final CountDownLatch latch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, final Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -1030,11 +1036,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "POST");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "POST");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter()
{
@ -1042,7 +1048,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
public void onReply(Stream stream, ReplyInfo replyInfo)
{
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
}).get(5, TimeUnit.SECONDS);
@ -1057,7 +1063,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final byte[] data = new byte[2000];
final CountDownLatch latch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, final Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -1093,11 +1099,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "POST");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "POST");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch replyLatch = new CountDownLatch(1);
Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter()
{
@ -1105,7 +1111,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
public void onReply(Stream stream, ReplyInfo replyInfo)
{
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
replyLatch.countDown();
}
}).get(5, TimeUnit.SECONDS);
@ -1121,7 +1127,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
final byte[] data = new byte[1000];
final CountDownLatch latch = new CountDownLatch(1);
Session session = startClient(startHTTPServer(new AbstractHandler()
Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler()
{
@Override
public void handle(String target, final Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
@ -1166,11 +1172,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
}), null);
Headers headers = new Headers();
headers.put("method", "POST");
headers.put("url", "/foo");
headers.put("version", "HTTP/1.1");
headers.put("scheme", "http");
headers.put("host", "localhost:" + connector.getLocalPort());
headers.put(HTTPSPDYHeader.METHOD.name(version()), "POST");
headers.put(HTTPSPDYHeader.URI.name(version()), "/foo");
headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1");
headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http");
headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort());
final CountDownLatch responseLatch = new CountDownLatch(2);
Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter()
{
@ -1178,7 +1184,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
public void onReply(Stream stream, ReplyInfo replyInfo)
{
Headers replyHeaders = replyInfo.getHeaders();
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200"));
responseLatch.countDown();
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.jetty.spdy.http;
import org.eclipse.jetty.spdy.api.SPDY;
public class ServerHTTPSPDYv3Test extends ServerHTTPSPDYv2Test
{
@Override
protected short version()
{
return SPDY.V3;
}
}

View File

@ -50,6 +50,11 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory
this.listener = listener;
}
public short getVersion()
{
return version;
}
@Override
public AsyncConnection newAsyncConnection(SocketChannel channel, AsyncEndPoint endPoint, Object attachment)
{