Refactored class Fields to a better API.
This commit is contained in:
parent
0d8956cad8
commit
2d6190da59
|
@ -523,13 +523,13 @@ public class HttpRequest implements Request
|
||||||
for (Iterator<Fields.Field> iterator = params.iterator(); iterator.hasNext();)
|
for (Iterator<Fields.Field> iterator = params.iterator(); iterator.hasNext();)
|
||||||
{
|
{
|
||||||
Fields.Field field = iterator.next();
|
Fields.Field field = iterator.next();
|
||||||
String[] values = field.values();
|
List<String> values = field.getValues();
|
||||||
for (int i = 0; i < values.length; ++i)
|
for (int i = 0; i < values.size(); ++i)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
result.append("&");
|
result.append("&");
|
||||||
result.append(field.name()).append("=");
|
result.append(field.getName()).append("=");
|
||||||
result.append(urlEncode(values[i]));
|
result.append(urlEncode(values.get(i)));
|
||||||
}
|
}
|
||||||
if (iterator.hasNext())
|
if (iterator.hasNext())
|
||||||
result.append("&");
|
result.append("&");
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(path, request.getPath());
|
Assert.assertEquals(path, request.getPath());
|
||||||
Assert.assertNull(request.getQuery());
|
Assert.assertNull(request.getQuery());
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(0, params.size());
|
Assert.assertEquals(0, params.getSize());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(path));
|
Assert.assertTrue(request.getURI().toString().endsWith(path));
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
@ -118,8 +118,8 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assert.assertEquals(query, request.getQuery());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(1, params.size());
|
Assert.assertEquals(1, params.getSize());
|
||||||
Assert.assertEquals(value, params.get(name).value());
|
Assert.assertEquals(value, params.get(name).getValue());
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
|
||||||
|
@ -155,8 +155,8 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assert.assertEquals(query, request.getQuery());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(1, params.size());
|
Assert.assertEquals(1, params.getSize());
|
||||||
Assert.assertEquals(value, params.get(name).value());
|
Assert.assertEquals(value, params.get(name).getValue());
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
|
||||||
|
@ -194,9 +194,9 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assert.assertEquals(query, request.getQuery());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(2, params.size());
|
Assert.assertEquals(2, params.getSize());
|
||||||
Assert.assertEquals(value1, params.get(name1).value());
|
Assert.assertEquals(value1, params.get(name1).getValue());
|
||||||
Assert.assertEquals(value2, params.get(name2).value());
|
Assert.assertEquals(value2, params.get(name2).getValue());
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
|
||||||
|
@ -238,9 +238,9 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assert.assertEquals(query, request.getQuery());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(2, params.size());
|
Assert.assertEquals(2, params.getSize());
|
||||||
Assert.assertEquals(value1, params.get(name1).value());
|
Assert.assertEquals(value1, params.get(name1).getValue());
|
||||||
Assert.assertEquals(value2, params.get(name2).value());
|
Assert.assertEquals(value2, params.get(name2).getValue());
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assert.assertEquals(query, request.getQuery());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(0, params.size());
|
Assert.assertEquals(0, params.getSize());
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assert.assertEquals(query, request.getQuery());
|
||||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||||
Fields params = request.getParams();
|
Fields params = request.getParams();
|
||||||
Assert.assertEquals(0, params.size());
|
Assert.assertEquals(0, params.getSize());
|
||||||
|
|
||||||
ContentResponse response = request.send();
|
ContentResponse response = request.send();
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.spdy.generator;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.eclipse.jetty.spdy.CompressionDictionary;
|
import org.eclipse.jetty.spdy.CompressionDictionary;
|
||||||
|
@ -42,24 +43,24 @@ public class HeadersBlockGenerator
|
||||||
{
|
{
|
||||||
// TODO: ByteArrayOutputStream is quite inefficient, but grows on demand; optimize using ByteBuffer ?
|
// TODO: ByteArrayOutputStream is quite inefficient, but grows on demand; optimize using ByteBuffer ?
|
||||||
Charset iso1 = Charset.forName("ISO-8859-1");
|
Charset iso1 = Charset.forName("ISO-8859-1");
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(headers.size() * 64);
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream(headers.getSize() * 64);
|
||||||
writeCount(version, buffer, headers.size());
|
writeCount(version, buffer, headers.getSize());
|
||||||
for (Fields.Field header : headers)
|
for (Fields.Field header : headers)
|
||||||
{
|
{
|
||||||
String name = header.name().toLowerCase(Locale.ENGLISH);
|
String name = header.getName().toLowerCase(Locale.ENGLISH);
|
||||||
byte[] nameBytes = name.getBytes(iso1);
|
byte[] nameBytes = name.getBytes(iso1);
|
||||||
writeNameLength(version, buffer, nameBytes.length);
|
writeNameLength(version, buffer, nameBytes.length);
|
||||||
buffer.write(nameBytes, 0, nameBytes.length);
|
buffer.write(nameBytes, 0, nameBytes.length);
|
||||||
|
|
||||||
// Most common path first
|
// Most common path first
|
||||||
String value = header.value();
|
String value = header.getValue();
|
||||||
byte[] valueBytes = value.getBytes(iso1);
|
byte[] valueBytes = value.getBytes(iso1);
|
||||||
if (header.hasMultipleValues())
|
if (header.hasMultipleValues())
|
||||||
{
|
{
|
||||||
String[] values = header.values();
|
List<String> values = header.getValues();
|
||||||
for (int i = 1; i < values.length; ++i)
|
for (int i = 1; i < values.size(); ++i)
|
||||||
{
|
{
|
||||||
byte[] moreValueBytes = values[i].getBytes(iso1);
|
byte[] moreValueBytes = values.get(i).getBytes(iso1);
|
||||||
byte[] newValueBytes = new byte[valueBytes.length + 1 + moreValueBytes.length];
|
byte[] newValueBytes = new byte[valueBytes.length + 1 + moreValueBytes.length];
|
||||||
System.arraycopy(valueBytes, 0, newValueBytes, 0, valueBytes.length);
|
System.arraycopy(valueBytes, 0, newValueBytes, 0, valueBytes.length);
|
||||||
newValueBytes[valueBytes.length] = 0;
|
newValueBytes[valueBytes.length] = 0;
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class ClientUsageTest
|
||||||
{
|
{
|
||||||
// Do something with the response
|
// Do something with the response
|
||||||
Fields headers = replyInfo.getHeaders();
|
Fields headers = replyInfo.getHeaders();
|
||||||
int contentLength = headers.get("content-length").valueAsInt();
|
int contentLength = headers.get("content-length").getValueAsInt();
|
||||||
stream.setAttribute("content-length", contentLength);
|
stream.setAttribute("content-length", contentLength);
|
||||||
if (!replyInfo.isClose())
|
if (!replyInfo.isClose())
|
||||||
stream.setAttribute("builder", new StringBuilder());
|
stream.setAttribute("builder", new StringBuilder());
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.spdy.frames;
|
package org.eclipse.jetty.spdy.frames;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||||
|
@ -34,6 +30,10 @@ import org.eclipse.jetty.util.Fields;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class HeadersGenerateParseTest
|
public class HeadersGenerateParseTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class HeadersGenerateParseTest
|
||||||
parser.parse(createHeadersFrameBuffer(headers));
|
parser.parse(createHeadersFrameBuffer(headers));
|
||||||
HeadersFrame parsedHeadersFrame = assertExpectationsAreMet(headers);
|
HeadersFrame parsedHeadersFrame = assertExpectationsAreMet(headers);
|
||||||
Fields.Field viaHeader = parsedHeadersFrame.getHeaders().get("via");
|
Fields.Field viaHeader = parsedHeadersFrame.getHeaders().get("via");
|
||||||
assertThat("Via Header name is lowercase", viaHeader.name(), is("via"));
|
assertThat("Via Header name is lowercase", viaHeader.getName(), is("via"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private HeadersFrame assertExpectationsAreMet(Fields headers)
|
private HeadersFrame assertExpectationsAreMet(Fields headers)
|
||||||
|
|
|
@ -62,9 +62,9 @@ public class HttpReceiverOverSPDY extends HttpReceiver implements StreamFrameLis
|
||||||
|
|
||||||
Fields fields = replyInfo.getHeaders();
|
Fields fields = replyInfo.getHeaders();
|
||||||
short spdy = stream.getSession().getVersion();
|
short spdy = stream.getSession().getVersion();
|
||||||
HttpVersion version = HttpVersion.fromString(fields.get(HTTPSPDYHeader.VERSION.name(spdy)).value());
|
HttpVersion version = HttpVersion.fromString(fields.get(HTTPSPDYHeader.VERSION.name(spdy)).getValue());
|
||||||
response.version(version);
|
response.version(version);
|
||||||
String[] status = fields.get(HTTPSPDYHeader.STATUS.name(spdy)).value().split(" ", 2);
|
String[] status = fields.get(HTTPSPDYHeader.STATUS.name(spdy)).getValue().split(" ", 2);
|
||||||
|
|
||||||
Integer code = Integer.parseInt(status[0]);
|
Integer code = Integer.parseInt(status[0]);
|
||||||
response.status(code);
|
response.status(code);
|
||||||
|
@ -75,11 +75,11 @@ public class HttpReceiverOverSPDY extends HttpReceiver implements StreamFrameLis
|
||||||
{
|
{
|
||||||
for (Fields.Field field : fields)
|
for (Fields.Field field : fields)
|
||||||
{
|
{
|
||||||
String name = field.name();
|
String name = field.getName();
|
||||||
if (HTTPSPDYHeader.from(spdy, name) != null)
|
if (HTTPSPDYHeader.from(spdy, name) != null)
|
||||||
continue;
|
continue;
|
||||||
// TODO: handle multiple values properly
|
// TODO: handle multiple values properly
|
||||||
HttpField httpField = new HttpField(name, field.value());
|
HttpField httpField = new HttpField(name, field.getValue());
|
||||||
responseHeader(exchange, httpField);
|
responseHeader(exchange, httpField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class HTTPSPDYServerConnectionFactory extends SPDYServerConnectionFactory
|
||||||
// if clients have to accept it.
|
// if clients have to accept it.
|
||||||
// So we inject the accept-encoding header here, even if not set by the client. This will enforce SPDY
|
// So we inject the accept-encoding header here, even if not set by the client. This will enforce SPDY
|
||||||
// clients to follow the spec and enable gzip compression if GzipFilter or the like is enabled.
|
// clients to follow the spec and enable gzip compression if GzipFilter or the like is enabled.
|
||||||
if (!(headers.get("accept-encoding") != null && headers.get("accept-encoding").value().contains
|
if (!(headers.get("accept-encoding") != null && headers.get("accept-encoding").getValue().contains
|
||||||
("gzip")))
|
("gzip")))
|
||||||
headers.add("accept-encoding", "gzip");
|
headers.add("accept-encoding", "gzip");
|
||||||
HttpTransportOverSPDY transport = new HttpTransportOverSPDY(connector, httpConfiguration, endPoint,
|
HttpTransportOverSPDY transport = new HttpTransportOverSPDY(connector, httpConfiguration, endPoint,
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
package org.eclipse.jetty.spdy.server.http;
|
package org.eclipse.jetty.spdy.server.http;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.http.HttpField;
|
import org.eclipse.jetty.http.HttpField;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
|
@ -172,19 +170,19 @@ public class HttpChannelOverSPDY extends HttpChannel<DataInfo>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpMethod httpMethod = HttpMethod.fromString(methodHeader.value());
|
HttpMethod httpMethod = HttpMethod.fromString(methodHeader.getValue());
|
||||||
HttpVersion httpVersion = HttpVersion.fromString(versionHeader.value());
|
HttpVersion httpVersion = HttpVersion.fromString(versionHeader.getValue());
|
||||||
|
|
||||||
// TODO should handle URI as byte buffer as some bad clients send WRONG encodings in query string
|
// TODO should handle URI as byte buffer as some bad clients send WRONG encodings in query string
|
||||||
// that we have to deal with
|
// that we have to deal with
|
||||||
ByteBuffer uri = BufferUtil.toBuffer(uriHeader.value());
|
ByteBuffer uri = BufferUtil.toBuffer(uriHeader.getValue());
|
||||||
|
|
||||||
LOG.debug("HTTP > {} {} {}", httpMethod, uriHeader.value(), httpVersion);
|
LOG.debug("HTTP > {} {} {}", httpMethod, uriHeader.getValue(), httpVersion);
|
||||||
startRequest(httpMethod, httpMethod.asString(), uri, httpVersion);
|
startRequest(httpMethod, httpMethod.asString(), uri, httpVersion);
|
||||||
|
|
||||||
Fields.Field schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version));
|
Fields.Field schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version));
|
||||||
if (schemeHeader != null)
|
if (schemeHeader != null)
|
||||||
getRequest().setScheme(schemeHeader.value());
|
getRequest().setScheme(schemeHeader.getValue());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +190,7 @@ public class HttpChannelOverSPDY extends HttpChannel<DataInfo>
|
||||||
{
|
{
|
||||||
for (Fields.Field header : headers)
|
for (Fields.Field header : headers)
|
||||||
{
|
{
|
||||||
String name = header.name();
|
String name = header.getName();
|
||||||
|
|
||||||
// Skip special SPDY headers, unless it's the "host" header
|
// Skip special SPDY headers, unless it's the "host" header
|
||||||
HTTPSPDYHeader specialHeader = HTTPSPDYHeader.from(stream.getSession().getVersion(), name);
|
HTTPSPDYHeader specialHeader = HTTPSPDYHeader.from(stream.getSession().getVersion(), name);
|
||||||
|
@ -217,7 +215,7 @@ public class HttpChannelOverSPDY extends HttpChannel<DataInfo>
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// Spec says headers must be single valued
|
// Spec says headers must be single valued
|
||||||
String value = header.value();
|
String value = header.getValue();
|
||||||
LOG.debug("HTTP > {}: {}", name, value);
|
LOG.debug("HTTP > {}: {}", name, value);
|
||||||
parsedHeader(new HttpField(name,value));
|
parsedHeader(new HttpField(name,value));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
// info!=null content!=null lastContent==false reply, commit with content
|
// info!=null content!=null lastContent==false reply, commit with content
|
||||||
// info!=null content!=null lastContent==true reply, commit with content and complete
|
// info!=null content!=null lastContent==true reply, commit with content and complete
|
||||||
|
|
||||||
boolean isHeadRequest = HttpMethod.HEAD.name().equalsIgnoreCase(requestHeaders.get(HTTPSPDYHeader.METHOD.name(version)).value());
|
boolean isHeadRequest = HttpMethod.HEAD.name().equalsIgnoreCase(requestHeaders.get(HTTPSPDYHeader.METHOD.name(version)).getValue());
|
||||||
boolean hasContent = BufferUtil.hasContent(content) && !isHeadRequest;
|
boolean hasContent = BufferUtil.hasContent(content) && !isHeadRequest;
|
||||||
boolean close = !hasContent && lastContent;
|
boolean close = !hasContent && lastContent;
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
stream.headers(new HeadersInfo(replyInfo.getHeaders(), replyInfo.isClose()), callback);
|
stream.headers(new HeadersInfo(replyInfo.getHeaders(), replyInfo.isClose()), callback);
|
||||||
|
|
||||||
Fields responseHeaders = replyInfo.getHeaders();
|
Fields responseHeaders = replyInfo.getHeaders();
|
||||||
if (responseHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().startsWith("200") && !stream.isClosed())
|
if (responseHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().startsWith("200") && !stream.isClosed())
|
||||||
{
|
{
|
||||||
Set<String> pushResources = pushStrategy.apply(stream, requestHeaders, responseHeaders);
|
Set<String> pushResources = pushStrategy.apply(stream, requestHeaders, responseHeaders);
|
||||||
if (pushResources.size() > 0)
|
if (pushResources.size() > 0)
|
||||||
|
@ -353,7 +353,7 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
newRequestHeaders.put(scheme);
|
newRequestHeaders.put(scheme);
|
||||||
newRequestHeaders.put(host);
|
newRequestHeaders.put(host);
|
||||||
newRequestHeaders.put(HTTPSPDYHeader.URI.name(version), pushResourcePath);
|
newRequestHeaders.put(HTTPSPDYHeader.URI.name(version), pushResourcePath);
|
||||||
String referrer = scheme.value() + "://" + host.value() + uri.value();
|
String referrer = scheme.getValue() + "://" + host.getValue() + uri.getValue();
|
||||||
newRequestHeaders.put("referer", referrer);
|
newRequestHeaders.put("referer", referrer);
|
||||||
newRequestHeaders.put("x-spdy-push", "true");
|
newRequestHeaders.put("x-spdy-push", "true");
|
||||||
return newRequestHeaders;
|
return newRequestHeaders;
|
||||||
|
@ -363,7 +363,7 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
{
|
{
|
||||||
final Fields pushHeaders = new Fields();
|
final Fields pushHeaders = new Fields();
|
||||||
if (version == SPDY.V2)
|
if (version == SPDY.V2)
|
||||||
pushHeaders.put(HTTPSPDYHeader.URI.name(version), scheme.value() + "://" + host.value() + pushResourcePath);
|
pushHeaders.put(HTTPSPDYHeader.URI.name(version), scheme.getValue() + "://" + host.getValue() + pushResourcePath);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushHeaders.put(HTTPSPDYHeader.URI.name(version), pushResourcePath);
|
pushHeaders.put(HTTPSPDYHeader.URI.name(version), pushResourcePath);
|
||||||
|
|
|
@ -160,12 +160,12 @@ public class ReferrerPushStrategy implements PushStrategy
|
||||||
Set<String> result = Collections.<String>emptySet();
|
Set<String> result = Collections.<String>emptySet();
|
||||||
short version = stream.getSession().getVersion();
|
short version = stream.getSession().getVersion();
|
||||||
if (!isIfModifiedSinceHeaderPresent(requestHeaders) && isValidMethod(requestHeaders.get(HTTPSPDYHeader.METHOD
|
if (!isIfModifiedSinceHeaderPresent(requestHeaders) && isValidMethod(requestHeaders.get(HTTPSPDYHeader.METHOD
|
||||||
.name(version)).value()) && !isUserAgentBlacklisted(requestHeaders))
|
.name(version)).getValue()) && !isUserAgentBlacklisted(requestHeaders))
|
||||||
{
|
{
|
||||||
String scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)).value();
|
String scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)).getValue();
|
||||||
String host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)).value();
|
String host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)).getValue();
|
||||||
String origin = scheme + "://" + host;
|
String origin = scheme + "://" + host;
|
||||||
String url = requestHeaders.get(HTTPSPDYHeader.URI.name(version)).value();
|
String url = requestHeaders.get(HTTPSPDYHeader.URI.name(version)).getValue();
|
||||||
String absoluteURL = origin + url;
|
String absoluteURL = origin + url;
|
||||||
LOG.debug("Applying push strategy for {}", absoluteURL);
|
LOG.debug("Applying push strategy for {}", absoluteURL);
|
||||||
if (isMainResource(url, responseHeaders))
|
if (isMainResource(url, responseHeaders))
|
||||||
|
@ -178,7 +178,7 @@ public class ReferrerPushStrategy implements PushStrategy
|
||||||
Fields.Field referrerHeader = requestHeaders.get("referer");
|
Fields.Field referrerHeader = requestHeaders.get("referer");
|
||||||
if (referrerHeader != null)
|
if (referrerHeader != null)
|
||||||
{
|
{
|
||||||
String referrer = referrerHeader.value();
|
String referrer = referrerHeader.getValue();
|
||||||
MainResource mainResource = mainResources.get(referrer);
|
MainResource mainResource = mainResources.get(referrer);
|
||||||
if (mainResource == null)
|
if (mainResource == null)
|
||||||
mainResource = getOrCreateMainResource(referrer);
|
mainResource = getOrCreateMainResource(referrer);
|
||||||
|
@ -237,7 +237,7 @@ public class ReferrerPushStrategy implements PushStrategy
|
||||||
Fields.Field userAgentHeader = headers.get("user-agent");
|
Fields.Field userAgentHeader = headers.get("user-agent");
|
||||||
if (userAgentHeader != null)
|
if (userAgentHeader != null)
|
||||||
for (Pattern userAgentPattern : userAgentBlacklist)
|
for (Pattern userAgentPattern : userAgentBlacklist)
|
||||||
if (userAgentPattern.matcher(userAgentHeader.value()).matches())
|
if (userAgentPattern.matcher(userAgentHeader.getValue()).matches())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ public class ReferrerPushStrategy implements PushStrategy
|
||||||
if (header == null)
|
if (header == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
String contentType = header.value().toLowerCase(Locale.ENGLISH);
|
String contentType = header.getValue().toLowerCase(Locale.ENGLISH);
|
||||||
for (String pushContentType : pushContentTypes)
|
for (String pushContentType : pushContentTypes)
|
||||||
if (contentType.startsWith(pushContentType))
|
if (contentType.startsWith(pushContentType))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class HTTPProxyEngine extends ProxyEngine
|
||||||
public StreamFrameListener proxy(final Stream clientStream, SynInfo clientSynInfo, ProxyEngineSelector.ProxyServerInfo proxyServerInfo)
|
public StreamFrameListener proxy(final Stream clientStream, SynInfo clientSynInfo, ProxyEngineSelector.ProxyServerInfo proxyServerInfo)
|
||||||
{
|
{
|
||||||
short version = clientStream.getSession().getVersion();
|
short version = clientStream.getSession().getVersion();
|
||||||
String method = clientSynInfo.getHeaders().get(HTTPSPDYHeader.METHOD.name(version)).value();
|
String method = clientSynInfo.getHeaders().get(HTTPSPDYHeader.METHOD.name(version)).getValue();
|
||||||
String path = clientSynInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).value();
|
String path = clientSynInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).getValue();
|
||||||
|
|
||||||
Fields headers = new Fields(clientSynInfo.getHeaders(), false);
|
Fields headers = new Fields(clientSynInfo.getHeaders(), false);
|
||||||
|
|
||||||
|
@ -249,8 +249,8 @@ public class HTTPProxyEngine extends ProxyEngine
|
||||||
private void addNonSpdyHeadersToRequest(short version, Fields headers, Request request)
|
private void addNonSpdyHeadersToRequest(short version, Fields headers, Request request)
|
||||||
{
|
{
|
||||||
for (Fields.Field header : headers)
|
for (Fields.Field header : headers)
|
||||||
if (HTTPSPDYHeader.from(version, header.name()) == null)
|
if (HTTPSPDYHeader.from(version, header.getName()) == null)
|
||||||
request.header(header.name(), header.value());
|
request.header(header.getName(), header.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
static class LoggingCallback extends Callback.Adapter
|
static class LoggingCallback extends Callback.Adapter
|
||||||
|
|
|
@ -98,7 +98,7 @@ public abstract class ProxyEngine
|
||||||
addViaHeader(headers);
|
addViaHeader(headers);
|
||||||
Fields.Field schemeField = headers.get(HTTPSPDYHeader.SCHEME.name(stream.getSession().getVersion()));
|
Fields.Field schemeField = headers.get(HTTPSPDYHeader.SCHEME.name(stream.getSession().getVersion()));
|
||||||
if(schemeField != null)
|
if(schemeField != null)
|
||||||
headers.add("X-Forwarded-Proto", schemeField.value());
|
headers.add("X-Forwarded-Proto", schemeField.getValue());
|
||||||
InetSocketAddress address = stream.getSession().getRemoteAddress();
|
InetSocketAddress address = stream.getSession().getRemoteAddress();
|
||||||
if (address != null)
|
if (address != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ProxyEngineSelector extends ServerSessionFrameListener.Adapter
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String host = hostHeader.value();
|
String host = hostHeader.getValue();
|
||||||
int colon = host.indexOf(':');
|
int colon = host.indexOf(':');
|
||||||
if (colon >= 0)
|
if (colon >= 0)
|
||||||
host = host.substring(0, colon);
|
host = host.substring(0, colon);
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
|
||||||
public void rst(RstInfo rstInfo, Callback handler)
|
public void rst(RstInfo rstInfo, Callback handler)
|
||||||
{
|
{
|
||||||
HttpGenerator.ResponseInfo info = new HttpGenerator.ResponseInfo(HttpVersion.fromString(headers.get
|
HttpGenerator.ResponseInfo info = new HttpGenerator.ResponseInfo(HttpVersion.fromString(headers.get
|
||||||
("version").value()), null, 0, 502, "SPDY reset received from upstream server", false);
|
("version").getValue()), null, 0, 502, "SPDY reset received from upstream server", false);
|
||||||
send(info, null, true, new Callback.Adapter());
|
send(info, null, true, new Callback.Adapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,24 +247,24 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
|
||||||
|
|
||||||
headers.remove(HTTPSPDYHeader.SCHEME.name(version));
|
headers.remove(HTTPSPDYHeader.SCHEME.name(version));
|
||||||
|
|
||||||
String status = headers.remove(HTTPSPDYHeader.STATUS.name(version)).value();
|
String status = headers.remove(HTTPSPDYHeader.STATUS.name(version)).getValue();
|
||||||
Matcher matcher = statusRegexp.matcher(status);
|
Matcher matcher = statusRegexp.matcher(status);
|
||||||
matcher.matches();
|
matcher.matches();
|
||||||
int code = Integer.parseInt(matcher.group(1));
|
int code = Integer.parseInt(matcher.group(1));
|
||||||
String reason = matcher.group(2).trim();
|
String reason = matcher.group(2).trim();
|
||||||
|
|
||||||
HttpVersion httpVersion = HttpVersion.fromString(headers.remove(HTTPSPDYHeader.VERSION.name(version)).value());
|
HttpVersion httpVersion = HttpVersion.fromString(headers.remove(HTTPSPDYHeader.VERSION.name(version)).getValue());
|
||||||
|
|
||||||
// Convert the Host header from a SPDY special header to a normal header
|
// Convert the Host header from a SPDY special header to a normal header
|
||||||
Fields.Field host = headers.remove(HTTPSPDYHeader.HOST.name(version));
|
Fields.Field host = headers.remove(HTTPSPDYHeader.HOST.name(version));
|
||||||
if (host != null)
|
if (host != null)
|
||||||
headers.put("host", host.value());
|
headers.put("host", host.getValue());
|
||||||
|
|
||||||
HttpFields fields = new HttpFields();
|
HttpFields fields = new HttpFields();
|
||||||
for (Fields.Field header : headers)
|
for (Fields.Field header : headers)
|
||||||
{
|
{
|
||||||
String name = camelize(header.name());
|
String name = camelize(header.getName());
|
||||||
fields.put(name, header.value());
|
fields.put(name, header.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle better the HEAD last parameter
|
// TODO: handle better the HEAD last parameter
|
||||||
|
@ -326,7 +326,7 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
|
||||||
|
|
||||||
private void addPersistenceHeader(Fields headersToAddTo)
|
private void addPersistenceHeader(Fields headersToAddTo)
|
||||||
{
|
{
|
||||||
HttpVersion httpVersion = HttpVersion.fromString(headers.get("version").value());
|
HttpVersion httpVersion = HttpVersion.fromString(headers.get("version").getValue());
|
||||||
boolean persistent = false;
|
boolean persistent = false;
|
||||||
switch (httpVersion)
|
switch (httpVersion)
|
||||||
{
|
{
|
||||||
|
@ -334,9 +334,9 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
|
||||||
{
|
{
|
||||||
Fields.Field keepAliveHeader = headers.get(HttpHeader.KEEP_ALIVE.asString());
|
Fields.Field keepAliveHeader = headers.get(HttpHeader.KEEP_ALIVE.asString());
|
||||||
if(keepAliveHeader!=null)
|
if(keepAliveHeader!=null)
|
||||||
persistent = HttpHeaderValue.KEEP_ALIVE.asString().equals(keepAliveHeader.value());
|
persistent = HttpHeaderValue.KEEP_ALIVE.asString().equals(keepAliveHeader.getValue());
|
||||||
if (!persistent)
|
if (!persistent)
|
||||||
persistent = HttpMethod.CONNECT.is(headers.get("method").value());
|
persistent = HttpMethod.CONNECT.is(headers.get("method").getValue());
|
||||||
if (persistent)
|
if (persistent)
|
||||||
headersToAddTo.add(HttpHeader.CONNECTION.asString(), HttpHeaderValue.KEEP_ALIVE.asString());
|
headersToAddTo.add(HttpHeader.CONNECTION.asString(), HttpHeaderValue.KEEP_ALIVE.asString());
|
||||||
break;
|
break;
|
||||||
|
@ -345,11 +345,11 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
|
||||||
{
|
{
|
||||||
Fields.Field connectionHeader = headers.get(HttpHeader.CONNECTION.asString());
|
Fields.Field connectionHeader = headers.get(HttpHeader.CONNECTION.asString());
|
||||||
if(connectionHeader != null)
|
if(connectionHeader != null)
|
||||||
persistent = !HttpHeaderValue.CLOSE.asString().equals(connectionHeader.value());
|
persistent = !HttpHeaderValue.CLOSE.asString().equals(connectionHeader.getValue());
|
||||||
else
|
else
|
||||||
persistent = true;
|
persistent = true;
|
||||||
if (!persistent)
|
if (!persistent)
|
||||||
persistent = HttpMethod.CONNECT.is(headers.get("method").value());
|
persistent = HttpMethod.CONNECT.is(headers.get("method").getValue());
|
||||||
if (!persistent)
|
if (!persistent)
|
||||||
headersToAddTo.add(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
|
headersToAddTo.add(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -212,7 +212,7 @@ public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener
|
||||||
if (header != null)
|
if (header != null)
|
||||||
{
|
{
|
||||||
String toName = httpHeader.name(toVersion);
|
String toName = httpHeader.name(toVersion);
|
||||||
for (String value : header.values())
|
for (String value : header.getValues())
|
||||||
headers.add(toName, value);
|
headers.add(toName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class ConcurrentStreamsTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
slowClientLatch.countDown();
|
slowClientLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -104,7 +104,7 @@ public class ConcurrentStreamsTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
fastClientLatch.countDown();
|
fastClientLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -367,7 +367,7 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest
|
||||||
@Override
|
@Override
|
||||||
public StreamFrameListener onSyn(Stream stream, SynInfo synInfo)
|
public StreamFrameListener onSyn(Stream stream, SynInfo synInfo)
|
||||||
{
|
{
|
||||||
String path = synInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).value();
|
String path = synInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).getValue();
|
||||||
addPushedResource(path);
|
addPushedResource(path);
|
||||||
return new DataListener();
|
return new DataListener();
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
|
|
||||||
assertThat("Stream is unidirectional", stream.isUnidirectional(), is(true));
|
assertThat("Stream is unidirectional", stream.isUnidirectional(), is(true));
|
||||||
assertThat("URI header ends with css", pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version))
|
assertThat("URI header ends with css", pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version))
|
||||||
.value().endsWith
|
.getValue().endsWith
|
||||||
("" +
|
("" +
|
||||||
".css"),
|
".css"),
|
||||||
is(true));
|
is(true));
|
||||||
|
@ -279,7 +279,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
public StreamFrameListener onPush(Stream stream, PushInfo pushInfo)
|
public StreamFrameListener onPush(Stream stream, PushInfo pushInfo)
|
||||||
{
|
{
|
||||||
LOG.info("onPush: stream: {}, pushInfo: {}", stream, pushInfo);
|
LOG.info("onPush: stream: {}, pushInfo: {}", stream, pushInfo);
|
||||||
String uriHeader = pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).value();
|
String uriHeader = pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).getValue();
|
||||||
switch ((int)allExpectedPushesReceivedLatch.getCount())
|
switch ((int)allExpectedPushesReceivedLatch.getCount())
|
||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -377,7 +377,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
public StreamFrameListener onPush(Stream stream, PushInfo pushInfo)
|
public StreamFrameListener onPush(Stream stream, PushInfo pushInfo)
|
||||||
{
|
{
|
||||||
LOG.info("Received push for stream: {} {}", stream.getId(), pushInfo);
|
LOG.info("Received push for stream: {} {}", stream.getId(), pushInfo);
|
||||||
String uriHeader = pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).value();
|
String uriHeader = pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).getValue();
|
||||||
switch ((int)allExpectedPushesReceivedLatch.getCount())
|
switch ((int)allExpectedPushesReceivedLatch.getCount())
|
||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -474,7 +474,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
|
|
||||||
assertThat("Stream is unidirectional", stream.isUnidirectional(), is(true));
|
assertThat("Stream is unidirectional", stream.isUnidirectional(), is(true));
|
||||||
assertThat("URI header ends with css", pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version))
|
assertThat("URI header ends with css", pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version))
|
||||||
.value().endsWith
|
.getValue().endsWith
|
||||||
("" +
|
("" +
|
||||||
".css"),
|
".css"),
|
||||||
is(true));
|
is(true));
|
||||||
|
@ -495,7 +495,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
@Override
|
@Override
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
assertThat(replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).value(), is("200 OK"));
|
assertThat(replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).getValue(), is("200 OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -527,7 +527,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
|
|
||||||
assertThat("Stream is unidirectional", stream.isUnidirectional(), is(true));
|
assertThat("Stream is unidirectional", stream.isUnidirectional(), is(true));
|
||||||
assertThat("URI header ends with css", pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version))
|
assertThat("URI header ends with css", pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version))
|
||||||
.value().endsWith
|
.getValue().endsWith
|
||||||
("" +
|
("" +
|
||||||
".css"),
|
".css"),
|
||||||
is(true));
|
is(true));
|
||||||
|
@ -747,7 +747,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
public StreamFrameListener onPush(Stream stream, PushInfo pushInfo)
|
public StreamFrameListener onPush(Stream stream, PushInfo pushInfo)
|
||||||
{
|
{
|
||||||
Assert.assertTrue(stream.isUnidirectional());
|
Assert.assertTrue(stream.isUnidirectional());
|
||||||
Assert.assertTrue(pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).value().endsWith("" +
|
Assert.assertTrue(pushInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version)).getValue().endsWith("" +
|
||||||
".css"));
|
".css"));
|
||||||
return new StreamFrameListener.Adapter()
|
return new StreamFrameListener.Adapter()
|
||||||
{
|
{
|
||||||
|
@ -1090,7 +1090,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
private boolean validateHeader(Fields headers, String name, String expectedValue)
|
private boolean validateHeader(Fields headers, String name, String expectedValue)
|
||||||
{
|
{
|
||||||
Fields.Field header = headers.get(name);
|
Fields.Field header = headers.get(name);
|
||||||
if (header != null && expectedValue.equals(header.value()))
|
if (header != null && expectedValue.equals(header.getValue()))
|
||||||
return true;
|
return true;
|
||||||
System.out.println(name + " not valid! Expected: " + expectedValue + " headers received:" + headers);
|
System.out.println(name + " not valid! Expected: " + expectedValue + " headers received:" + headers);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1100,9 +1100,9 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Fields.Field uriHeader = headers.get(HTTPSPDYHeader.URI.name(version));
|
Fields.Field uriHeader = headers.get(HTTPSPDYHeader.URI.name(version));
|
||||||
if (uriHeader != null)
|
if (uriHeader != null)
|
||||||
if (version == SPDY.V2 && uriHeader.value().startsWith("http://"))
|
if (version == SPDY.V2 && uriHeader.getValue().startsWith("http://"))
|
||||||
return true;
|
return true;
|
||||||
else if (version == SPDY.V3 && uriHeader.value().startsWith("/")
|
else if (version == SPDY.V3 && uriHeader.getValue().startsWith("/")
|
||||||
&& headers.get(HTTPSPDYHeader.HOST.name(version)) != null && headers.get(HTTPSPDYHeader.SCHEME.name(version)) != null)
|
&& headers.get(HTTPSPDYHeader.HOST.name(version)) != null && headers.get(HTTPSPDYHeader.SCHEME.name(version)) != null)
|
||||||
return true;
|
return true;
|
||||||
System.out.println(HTTPSPDYHeader.URI.name(version) + " not valid!");
|
System.out.println(HTTPSPDYHeader.URI.name(version) + " not valid!");
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class SSLExternalServerTest extends AbstractHTTPSPDYTest
|
||||||
Fields.Field versionHeader = headers.get(HTTPSPDYHeader.STATUS.name(version));
|
Fields.Field versionHeader = headers.get(HTTPSPDYHeader.STATUS.name(version));
|
||||||
if (versionHeader != null)
|
if (versionHeader != null)
|
||||||
{
|
{
|
||||||
Matcher matcher = Pattern.compile("(\\d{3}).*").matcher(versionHeader.value());
|
Matcher matcher = Pattern.compile("(\\d{3}).*").matcher(versionHeader.getValue());
|
||||||
if (matcher.matches() && Integer.parseInt(matcher.group(1)) < 400)
|
if (matcher.matches() && Integer.parseInt(matcher.group(1)) < 400)
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"), is(true));
|
assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"), is(true));
|
||||||
assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), is(notNullValue()));
|
assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), is(notNullValue()));
|
||||||
assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), is(notNullValue()));
|
assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), is(notNullValue()));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
|
@ -149,7 +149,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -192,11 +192,11 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertThat("isClose is true", replyInfo.isClose(), is(true));
|
assertThat("isClose is true", replyInfo.isClose(), is(true));
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertThat("response code is 200 OK", replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value()
|
assertThat("response code is 200 OK", replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue()
|
||||||
.contains("200"), is(true));
|
.contains("200"), is(true));
|
||||||
assertThat(replyInfo.getHeaders().get("Set-Cookie").values()[0], is(cookie1 + "=\"" + cookie1Value +
|
assertThat(replyInfo.getHeaders().get("Set-Cookie").getValues().get(0), is(cookie1 + "=\"" + cookie1Value +
|
||||||
"\";Version=1"));
|
"\";Version=1"));
|
||||||
assertThat(replyInfo.getHeaders().get("Set-Cookie").values()[1], is(cookie2 + "=\"" + cookie2Value +
|
assertThat(replyInfo.getHeaders().get("Set-Cookie").getValues().get(1), is(cookie2 + "=\"" + cookie2Value +
|
||||||
"\";Version=1"));
|
"\";Version=1"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -325,7 +325,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -367,7 +367,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -411,7 +411,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.toString(), replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.toString(), replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -453,7 +453,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
assertEquals(1, replyFrames.incrementAndGet());
|
assertEquals(1, replyFrames.incrementAndGet());
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,7 +827,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,8 +880,8 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
assertEquals(1, replies.incrementAndGet());
|
assertEquals(1, replies.incrementAndGet());
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("302"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("302"));
|
||||||
assertTrue(replyHeaders.get("location").value().endsWith(suffix));
|
assertTrue(replyHeaders.get("location").getValue().endsWith(suffix));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -918,7 +918,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
assertEquals(1, replies.incrementAndGet());
|
assertEquals(1, replies.incrementAndGet());
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("404"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("404"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertEquals(1, replies.incrementAndGet());
|
assertEquals(1, replies.incrementAndGet());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("500"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("500"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
if (replyInfo.isClose())
|
if (replyInfo.isClose())
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
@ -1018,8 +1018,8 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
assertEquals(1, replyFrames.incrementAndGet());
|
assertEquals(1, replyFrames.incrementAndGet());
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
assertTrue(replyHeaders.get("extra").value().contains("X"));
|
assertTrue(replyHeaders.get("extra").getValue().contains("X"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,7 +1077,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
assertEquals(1, replyFrames.incrementAndGet());
|
assertEquals(1, replyFrames.incrementAndGet());
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,7 +1130,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
Assert.assertFalse(replyInfo.isClose());
|
Assert.assertFalse(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1234,7 +1234,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1279,7 +1279,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1347,7 +1347,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1415,7 +1415,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
responseLatch.countDown();
|
responseLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1456,7 +1456,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
|
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"));
|
||||||
responseLatch.countDown();
|
responseLatch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class SimpleHTTPBenchmarkTest extends AbstractHTTPSPDYTest
|
||||||
{
|
{
|
||||||
assertTrue(replyInfo.isClose());
|
assertTrue(replyInfo.isClose());
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"), CoreMatchers.is(true));
|
assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"), CoreMatchers.is(true));
|
||||||
assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), CoreMatchers.is(notNullValue()));
|
assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), CoreMatchers.is(notNullValue()));
|
||||||
assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), CoreMatchers.is(notNullValue()));
|
assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), CoreMatchers.is(notNullValue()));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
|
@ -138,7 +138,7 @@ public class SimpleHTTPBenchmarkTest extends AbstractHTTPSPDYTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields replyHeaders = replyInfo.getHeaders();
|
Fields replyHeaders = replyInfo.getHeaders();
|
||||||
assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"), CoreMatchers.is(true));
|
assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).getValue().contains("200"), CoreMatchers.is(true));
|
||||||
assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), CoreMatchers.is(notNullValue()));
|
assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), CoreMatchers.is(notNullValue()));
|
||||||
assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), CoreMatchers.is(notNullValue()));
|
assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), CoreMatchers.is(notNullValue()));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
|
|
|
@ -317,7 +317,7 @@ public class ProxySPDYToHTTPTest
|
||||||
@Override
|
@Override
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
assertThat("Status code is 302", replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).value(),
|
assertThat("Status code is 302", replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).getValue(),
|
||||||
is("302"));
|
is("302"));
|
||||||
assertThat("Location header has been received", replyInfo.getHeaders().get("Location"), is(notNullValue()));
|
assertThat("Location header has been received", replyInfo.getHeaders().get("Location"), is(notNullValue()));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
|
@ -484,7 +484,7 @@ public class ProxySPDYToHTTPTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields headers = replyInfo.getHeaders();
|
Fields headers = replyInfo.getHeaders();
|
||||||
assertThat("status is 504", headers.get(HTTPSPDYHeader.STATUS.name(version)).value(), is("504"));
|
assertThat("status is 504", headers.get(HTTPSPDYHeader.STATUS.name(version)).getValue(), is("504"));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,8 +230,8 @@ public class ProxySPDYToSPDYLoadTest
|
||||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||||
{
|
{
|
||||||
Fields headers = replyInfo.getHeaders();
|
Fields headers = replyInfo.getHeaders();
|
||||||
assertThat("uuid matches expected uuid", headers.get(UUID_HEADER_NAME).value(), is(uuid));
|
assertThat("uuid matches expected uuid", headers.get(UUID_HEADER_NAME).getValue(), is(uuid));
|
||||||
assertThat("response comes from the given server", headers.get(SERVER_ID_HEADER).value(),
|
assertThat("response comes from the given server", headers.get(SERVER_ID_HEADER).getValue(),
|
||||||
is(serverIdentificationString));
|
is(serverIdentificationString));
|
||||||
replyLatch.countDown();
|
replyLatch.countDown();
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ public class ProxySPDYToSPDYLoadTest
|
||||||
Assert.assertNotNull(uuidHeader);
|
Assert.assertNotNull(uuidHeader);
|
||||||
|
|
||||||
Fields responseHeaders = new Fields();
|
Fields responseHeaders = new Fields();
|
||||||
responseHeaders.put(UUID_HEADER_NAME, uuidHeader.value());
|
responseHeaders.put(UUID_HEADER_NAME, uuidHeader.getValue());
|
||||||
responseHeaders.put(SERVER_ID_HEADER, serverId);
|
responseHeaders.put(SERVER_ID_HEADER, serverId);
|
||||||
stream.reply(new ReplyInfo(responseHeaders, false), new Callback.Adapter());
|
stream.reply(new ReplyInfo(responseHeaders, false), new Callback.Adapter());
|
||||||
return new StreamFrameListener.Adapter()
|
return new StreamFrameListener.Adapter()
|
||||||
|
|
|
@ -18,11 +18,13 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.util;
|
package org.eclipse.jetty.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -82,7 +84,7 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
if (obj == null || getClass() != obj.getClass())
|
if (obj == null || getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
Fields that = (Fields)obj;
|
Fields that = (Fields)obj;
|
||||||
if (size() != that.size())
|
if (getSize() != that.getSize())
|
||||||
return false;
|
return false;
|
||||||
if (caseSensitive != that.caseSensitive)
|
if (caseSensitive != that.caseSensitive)
|
||||||
return false;
|
return false;
|
||||||
|
@ -105,11 +107,11 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
/**
|
/**
|
||||||
* @return a set of field names
|
* @return a set of field names
|
||||||
*/
|
*/
|
||||||
public Set<String> names()
|
public Set<String> getNames()
|
||||||
{
|
{
|
||||||
Set<String> result = new LinkedHashSet<>();
|
Set<String> result = new LinkedHashSet<>();
|
||||||
for (Field field : fields.values())
|
for (Field field : fields.values())
|
||||||
result.add(field.name());
|
result.add(field.getName());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,14 +143,14 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Inserts or replaces the given {@link Field}, mapped to the {@link Field#name() field's name}</p>
|
* <p>Inserts or replaces the given {@link Field}, mapped to the {@link Field#getName() field's name}</p>
|
||||||
*
|
*
|
||||||
* @param field the field to put
|
* @param field the field to put
|
||||||
*/
|
*/
|
||||||
public void put(Field field)
|
public void put(Field field)
|
||||||
{
|
{
|
||||||
if (field != null)
|
if (field != null)
|
||||||
fields.put(normalizeName(field.name()), field);
|
fields.put(normalizeName(field.getName()), field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +172,7 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
field = new Field(field.name(), field.values(), value);
|
field = new Field(field.getName(), field.getValues(), value);
|
||||||
fields.put(key, field);
|
fields.put(key, field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +208,7 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
/**
|
/**
|
||||||
* @return the number of fields
|
* @return the number of fields
|
||||||
*/
|
*/
|
||||||
public int size()
|
public int getSize()
|
||||||
{
|
{
|
||||||
return fields.size();
|
return fields.size();
|
||||||
}
|
}
|
||||||
|
@ -233,19 +235,20 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
public static class Field
|
public static class Field
|
||||||
{
|
{
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String[] values;
|
private final List<String> values;
|
||||||
|
|
||||||
public Field(String name, String value)
|
public Field(String name, String value)
|
||||||
{
|
{
|
||||||
this(name, new String[]{value});
|
this(name, Collections.singletonList(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Field(String name, String[] values, String... moreValues)
|
private Field(String name, List<String> values, String... moreValues)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.values = new String[values.length + moreValues.length];
|
List<String> list = new ArrayList<>(values.size() + moreValues.length);
|
||||||
System.arraycopy(values, 0, this.values, 0, values.length);
|
list.addAll(values);
|
||||||
System.arraycopy(moreValues, 0, this.values, values.length, moreValues.length);
|
list.addAll(Arrays.asList(moreValues));
|
||||||
|
this.values = Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Field that, boolean caseSensitive)
|
public boolean equals(Field that, boolean caseSensitive)
|
||||||
|
@ -256,7 +259,7 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
return false;
|
return false;
|
||||||
if (caseSensitive)
|
if (caseSensitive)
|
||||||
return equals(that);
|
return equals(that);
|
||||||
return name.equalsIgnoreCase(that.name) && Arrays.equals(values, that.values);
|
return name.equalsIgnoreCase(that.name) && values.equals(that.values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -267,21 +270,21 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
if (obj == null || getClass() != obj.getClass())
|
if (obj == null || getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
Field that = (Field)obj;
|
Field that = (Field)obj;
|
||||||
return name.equals(that.name) && Arrays.equals(values, that.values);
|
return name.equals(that.name) && values.equals(that.values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
int result = name.hashCode();
|
int result = name.hashCode();
|
||||||
result = 31 * result + Arrays.hashCode(values);
|
result = 31 * result + values.hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the field's name
|
* @return the field's name
|
||||||
*/
|
*/
|
||||||
public String name()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -289,29 +292,29 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
/**
|
/**
|
||||||
* @return the first field's value
|
* @return the first field's value
|
||||||
*/
|
*/
|
||||||
public String value()
|
public String getValue()
|
||||||
{
|
{
|
||||||
return values[0];
|
return values.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Attempts to convert the result of {@link #value()} to an integer,
|
* <p>Attempts to convert the result of {@link #getValue()} to an integer,
|
||||||
* returning it if the conversion is successful; returns null if the
|
* returning it if the conversion is successful; returns null if the
|
||||||
* result of {@link #value()} is null.</p>
|
* result of {@link #getValue()} is null.</p>
|
||||||
*
|
*
|
||||||
* @return the result of {@link #value()} converted to an integer, or null
|
* @return the result of {@link #getValue()} converted to an integer, or null
|
||||||
* @throws NumberFormatException if the conversion fails
|
* @throws NumberFormatException if the conversion fails
|
||||||
*/
|
*/
|
||||||
public Integer valueAsInt()
|
public Integer getValueAsInt()
|
||||||
{
|
{
|
||||||
final String value = value();
|
final String value = getValue();
|
||||||
return value == null ? null : Integer.valueOf(value);
|
return value == null ? null : Integer.valueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the field's values
|
* @return the field's values
|
||||||
*/
|
*/
|
||||||
public String[] values()
|
public List<String> getValues()
|
||||||
{
|
{
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
@ -321,13 +324,13 @@ public class Fields implements Iterable<Fields.Field>
|
||||||
*/
|
*/
|
||||||
public boolean hasMultipleValues()
|
public boolean hasMultipleValues()
|
||||||
{
|
{
|
||||||
return values.length > 1;
|
return values.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return Arrays.toString(values);
|
return String.format("%s=%s", name, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue