From d8ed9116f113fe6dd10b45167eda9699abcea745 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 6 Sep 2012 13:22:04 +0200 Subject: [PATCH] jetty-9 - Moved SPDY's Headers class to jetty-util module as Fields. --- .../org/eclipse/jetty/http/HttpFields.java | 108 ++---------- .../eclipse/jetty/spdy/api/HeadersInfo.java | 16 +- .../org/eclipse/jetty/spdy/api/ReplyInfo.java | 14 +- .../org/eclipse/jetty/spdy/api/SynInfo.java | 24 +-- .../jetty/spdy/frames/HeadersFrame.java | 8 +- .../jetty/spdy/frames/SynReplyFrame.java | 8 +- .../jetty/spdy/frames/SynStreamFrame.java | 8 +- .../spdy/generator/HeadersBlockGenerator.java | 6 +- .../jetty/spdy/parser/HeadersBodyParser.java | 6 +- .../jetty/spdy/parser/SynReplyBodyParser.java | 6 +- .../spdy/parser/SynStreamBodyParser.java | 6 +- .../jetty/spdy/StandardSessionTest.java | 6 +- .../jetty/spdy/api/ClientUsageTest.java | 3 +- .../jetty/spdy/api/ServerUsageTest.java | 9 +- .../spdy/frames/HeadersGenerateParseTest.java | 12 +- .../frames/SynReplyGenerateParseTest.java | 6 +- .../frames/SynStreamGenerateParseTest.java | 6 +- .../spdy/parser/UnknownControlFrameTest.java | 4 +- .../jetty/spdy/http/HttpChannelOverSPDY.java | 20 +-- .../spdy/http/HttpTransportOverSPDY.java | 30 ++-- .../eclipse/jetty/spdy/http/PushStrategy.java | 6 +- .../jetty/spdy/http/ReferrerPushStrategy.java | 14 +- .../http/ServerHTTPSPDYConnectionFactory.java | 4 +- .../eclipse/jetty/spdy/proxy/ProxyEngine.java | 12 +- .../jetty/spdy/proxy/ProxyEngineSelector.java | 6 +- .../spdy/proxy/ProxyHTTPSPDYConnection.java | 10 +- .../jetty/spdy/proxy/SPDYProxyEngine.java | 12 +- .../spdy/http/ConcurrentStreamsTest.java | 8 +- .../spdy/http/PushStrategyBenchmarkTest.java | 10 +- .../spdy/http/ReferrerPushStrategyTest.java | 60 +++---- .../http/ReferrerPushStrategyUnitTest.java | 22 +-- .../spdy/http/SSLExternalServerTest.java | 8 +- .../jetty/spdy/http/ServerHTTPSPDYTest.java | 94 +++++----- .../jetty/spdy/proxy/ProxyHTTPSPDYTest.java | 48 ++--- .../eclipse/jetty/spdy/ClosedStreamTest.java | 6 +- .../org/eclipse/jetty/spdy/HeadersTest.java | 6 +- .../jetty/spdy/ProtocolViolationsTest.java | 6 +- .../eclipse/jetty/spdy/PushStreamTest.java | 4 +- .../jetty/spdy/SynDataReplyDataLoadTest.java | 8 +- .../org/eclipse/jetty/spdy/SynReplyTest.java | 6 +- .../jetty/spdy/UnsupportedVersionTest.java | 4 +- .../java/org/eclipse/jetty/util/Fields.java | 166 ++++++++---------- 42 files changed, 374 insertions(+), 452 deletions(-) rename jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java => jetty-util/src/main/java/org/eclipse/jetty/util/Fields.java (51%) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index 2f7377caf88..9c9862f8d52 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -46,7 +46,8 @@ import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -/* ------------------------------------------------------------ */ +// TODO: Make this class inherit from oej.util.Fields + /** * HTTP Fields. A collection of HTTP header and or Trailer fields. * @@ -57,30 +58,24 @@ import org.eclipse.jetty.util.log.Logger; public class HttpFields implements Iterable { private static final Logger LOG = Log.getLogger(HttpFields.class); - - /* ------------------------------------------------------------ */ public static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;="; public static final TimeZone __GMT = TimeZone.getTimeZone("GMT"); public static final DateCache __dateCache = new DateCache("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); - /* -------------------------------------------------------------- */ static { __GMT.setID("GMT"); __dateCache.setTimeZone(__GMT); } - /* ------------------------------------------------------------ */ public final static String __separators = ", \t"; - /* ------------------------------------------------------------ */ private static final String[] DAYS = { "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; private static final String[] MONTHS = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"}; - /* ------------------------------------------------------------ */ private static class DateGenerator { private final StringBuilder buf = new StringBuilder(32); @@ -126,7 +121,6 @@ public class HttpFields implements Iterable return buf.toString(); } - /* ------------------------------------------------------------ */ /** * Format "EEE, dd-MMM-yy HH:mm:ss 'GMT'" for cookies */ @@ -167,7 +161,6 @@ public class HttpFields implements Iterable } } - /* ------------------------------------------------------------ */ private static final ThreadLocal __dateGenerator =new ThreadLocal() { @Override @@ -177,7 +170,6 @@ public class HttpFields implements Iterable } }; - /* ------------------------------------------------------------ */ /** * Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'" */ @@ -186,7 +178,6 @@ public class HttpFields implements Iterable return __dateGenerator.get().formatDate(date); } - /* ------------------------------------------------------------ */ /** * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies */ @@ -195,7 +186,6 @@ public class HttpFields implements Iterable __dateGenerator.get().formatCookieDate(buf,date); } - /* ------------------------------------------------------------ */ /** * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies */ @@ -206,7 +196,6 @@ public class HttpFields implements Iterable return buf.toString(); } - /* ------------------------------------------------------------ */ private final static String __dateReceiveFmt[] = { "EEE, dd MMM yyyy HH:mm:ss zzz", @@ -222,7 +211,6 @@ public class HttpFields implements Iterable "EEE dd-MMM-yy HH:mm:ss zzz", "EEE dd-MMM-yy HH:mm:ss", }; - /* ------------------------------------------------------------ */ private static class DateParser { final SimpleDateFormat _dateReceive[]= new SimpleDateFormat[__dateReceiveFmt.length]; @@ -269,13 +257,11 @@ public class HttpFields implements Iterable } } - /* ------------------------------------------------------------ */ public static long parseDate(String date) { return __dateParser.get().parse(date); } - /* ------------------------------------------------------------ */ private static final ThreadLocal __dateParser =new ThreadLocal() { @Override @@ -285,16 +271,13 @@ public class HttpFields implements Iterable } }; - /* -------------------------------------------------------------- */ public final static String __01Jan1970=formatDate(0); public final static ByteBuffer __01Jan1970_BUFFER=BufferUtil.toBuffer(__01Jan1970); public final static String __01Jan1970_COOKIE = formatCookieDate(0).trim(); private final static byte[] __colon_space = new byte[] {':',' '}; - /* -------------------------------------------------------------- */ - private final ArrayList _fields = new ArrayList(20); - private final StringMap _names = new StringMap(true); + private final ArrayList _fields = new ArrayList<>(20); + private final StringMap _names = new StringMap<>(true); - /* ------------------------------------------------------------ */ /** * Constructor. */ @@ -303,13 +286,12 @@ public class HttpFields implements Iterable } - /* -------------------------------------------------------------- */ /** * Get Collection of header names. */ public Collection getFieldNamesCollection() { - final List list = new ArrayList(_fields.size()); + final List list = new ArrayList<>(_fields.size()); for (Field f : _fields) { if (f!=null) @@ -318,7 +300,6 @@ public class HttpFields implements Iterable return list; } - /* -------------------------------------------------------------- */ /** * Get enumeration of header _names. Returns an enumeration of strings representing the header * _names for this request. @@ -342,13 +323,11 @@ public class HttpFields implements Iterable }; } - /* ------------------------------------------------------------ */ public int size() { return _fields.size(); } - /* ------------------------------------------------------------ */ /** * Get a Field by index. * @return A Field value or null if the Field value has not been set @@ -359,50 +338,42 @@ public class HttpFields implements Iterable return _fields.get(i); } - /* ------------------------------------------------------------ */ @Override public Iterator iterator() { return _fields.iterator(); } - /* ------------------------------------------------------------ */ public Field getField(HttpHeader header) { return _names.get(header.toString()); } - /* ------------------------------------------------------------ */ public Field getField(String name) { return _names.get(name); } - /* ------------------------------------------------------------ */ public boolean containsKey(String name) { return _names.containsKey(name); } - /* -------------------------------------------------------------- */ public String getStringField(HttpHeader header) { return getStringField(header.asString()); } - /* -------------------------------------------------------------- */ public String get(HttpHeader header) { return getStringField(header.asString()); } - /* -------------------------------------------------------------- */ public String get(String header) { return getStringField(header); } - /* -------------------------------------------------------------- */ /** * @return the value of a field, or null if not found. For multiple fields of the same name, * only the first is returned. @@ -415,7 +386,6 @@ public class HttpFields implements Iterable } - /* -------------------------------------------------------------- */ /** * Get multi headers * @@ -428,7 +398,7 @@ public class HttpFields implements Iterable if (field==null) return null; - final List list = new ArrayList(); + final List list = new ArrayList<>(); while(field!=null) { @@ -438,7 +408,6 @@ public class HttpFields implements Iterable return list; } - /* -------------------------------------------------------------- */ /** * Get multi headers * @@ -475,7 +444,6 @@ public class HttpFields implements Iterable }; } - /* -------------------------------------------------------------- */ /** * Get multi field values with separator. The multiple values can be represented as separate * headers of the same name, or by a single header using the separator(s), or a combination of @@ -520,7 +488,6 @@ public class HttpFields implements Iterable } - /* -------------------------------------------------------------- */ /** * Set a field. * @@ -539,13 +506,11 @@ public class HttpFields implements Iterable _names.put(name, field); } - /* -------------------------------------------------------------- */ public void put(HttpHeader header, HttpHeaderValue value) { put(header,value.toString()); } - /* -------------------------------------------------------------- */ /** * Set a field. * @@ -564,7 +529,6 @@ public class HttpFields implements Iterable _names.put(header.toString(), field); } - /* -------------------------------------------------------------- */ /** * Set a field. * @@ -579,7 +543,6 @@ public class HttpFields implements Iterable add(name,v); } - /* -------------------------------------------------------------- */ /** * Add to or set a field. If the field is allowed to have multiple values, add will add multiple * headers of the same name. @@ -613,18 +576,16 @@ public class HttpFields implements Iterable _names.put(name, field); } - /* -------------------------------------------------------------- */ public void add(HttpHeader header, HttpHeaderValue value) throws IllegalArgumentException { add(header,value.toString()); } - /* -------------------------------------------------------------- */ /** * Add to or set a field. If the field is allowed to have multiple values, add will add multiple * headers of the same name. * - * @param name the name of the field + * @param header the header * @param value the value of the field. * @exception IllegalArgumentException If the name is a single valued field and already has a * value. @@ -652,22 +613,20 @@ public class HttpFields implements Iterable _names.put(header.toString(), field); } - /* ------------------------------------------------------------ */ /** * Remove a field. * - * @param name + * @param name the field to remove */ public void remove(HttpHeader name) { remove(name.toString()); } - /* ------------------------------------------------------------ */ /** * Remove a field. * - * @param name + * @param name the field to remove */ public void remove(String name) { @@ -679,7 +638,6 @@ public class HttpFields implements Iterable } } - /* -------------------------------------------------------------- */ /** * Get a header as an long value. Returns the value of an integer field or -1 if not found. The * case of the field name is ignored. @@ -693,7 +651,6 @@ public class HttpFields implements Iterable return field==null?-1L:field.getLongValue(); } - /* -------------------------------------------------------------- */ /** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. @@ -717,7 +674,6 @@ public class HttpFields implements Iterable } - /* -------------------------------------------------------------- */ /** * Sets the value of an long field. * @@ -730,7 +686,6 @@ public class HttpFields implements Iterable put(name, v); } - /* -------------------------------------------------------------- */ /** * Sets the value of an long field. * @@ -744,7 +699,6 @@ public class HttpFields implements Iterable } - /* -------------------------------------------------------------- */ /** * Sets the value of a date field. * @@ -757,7 +711,6 @@ public class HttpFields implements Iterable put(name, d); } - /* -------------------------------------------------------------- */ /** * Sets the value of a date field. * @@ -770,7 +723,6 @@ public class HttpFields implements Iterable put(name, d); } - /* -------------------------------------------------------------- */ /** * Sets the value of a date field. * @@ -783,7 +735,6 @@ public class HttpFields implements Iterable add(name,d); } - /* ------------------------------------------------------------ */ /** * Format a set cookie value * @@ -907,29 +858,25 @@ public class HttpFields implements Iterable put(HttpHeader.EXPIRES.toString(), __01Jan1970); } - /* -------------------------------------------------------------- */ public void putTo(ByteBuffer bufferInFillMode) throws IOException { - for (int i = 0; i < _fields.size(); i++) + for (Field field : _fields) { - Field field = _fields.get(i); if (field != null) field.putTo(bufferInFillMode); } BufferUtil.putCRLF(bufferInFillMode); } - /* -------------------------------------------------------------- */ @Override public String toString() { try { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < _fields.size(); i++) + StringBuilder buffer = new StringBuilder(); + for (Field field : _fields) { - Field field = _fields.get(i); if (field != null) { String tmp = field.getName(); @@ -950,7 +897,6 @@ public class HttpFields implements Iterable } } - /* ------------------------------------------------------------ */ /** * Clear the header. */ @@ -960,12 +906,11 @@ public class HttpFields implements Iterable _names.clear(); } - /* ------------------------------------------------------------ */ /** * Add fields from another HttpFields instance. Single valued fields are replaced, while all * others are added. * - * @param fields + * @param fields the fields to add */ public void add(HttpFields fields) { @@ -981,7 +926,6 @@ public class HttpFields implements Iterable } } - /* ------------------------------------------------------------ */ /** * Get field value parameters. Some field values can have parameters. This method separates the * value from the parameters and optionally populates a map with the parameters. For example: @@ -1021,7 +965,6 @@ public class HttpFields implements Iterable return value.substring(0, i).trim(); } - /* ------------------------------------------------------------ */ private static final Float __one = new Float("1.0"); private static final Float __zero = new Float("0.0"); private static final StringMap __qualities = new StringMap<>(); @@ -1045,7 +988,6 @@ public class HttpFields implements Iterable __qualities.put("0.0", __zero); } - /* ------------------------------------------------------------ */ public static Float getQuality(String value) { if (value == null) return __zero; @@ -1061,7 +1003,7 @@ public class HttpFields implements Iterable return q; } - Map params = new HashMap(4); + Map params = new HashMap<>(4); valueParameters(value, params); String qs = params.get("q"); if (qs==null) @@ -1081,7 +1023,6 @@ public class HttpFields implements Iterable return q; } - /* ------------------------------------------------------------ */ /** * List values in quality order. * @@ -1099,10 +1040,10 @@ public class HttpFields implements Iterable // Assume list will be well ordered and just add nonzero while (e.hasMoreElements()) { - String v = e.nextElement().toString(); + String v = e.nextElement(); Float q = getQuality(v); - if (q.floatValue() >= 0.001) + if (q >= 0.001) { list = LazyList.add(list, v); qual = LazyList.add(qual, q); @@ -1136,9 +1077,6 @@ public class HttpFields implements Iterable return vl; } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ public static final class Field { private final HttpHeader _header; @@ -1146,7 +1084,6 @@ public class HttpFields implements Iterable private final String _value; private Field _next; - /* ------------------------------------------------------------ */ private Field(HttpHeader header, String value) { _header = header; @@ -1155,7 +1092,6 @@ public class HttpFields implements Iterable _next = null; } - /* ------------------------------------------------------------ */ private Field(String name, String value) { _header = HttpHeader.CACHE.get(name); @@ -1164,7 +1100,6 @@ public class HttpFields implements Iterable _next = null; } - /* ------------------------------------------------------------ */ private byte[] toSanitisedName(String s) { byte[] bytes = s.getBytes(StringUtil.__ISO_8859_1_CHARSET); @@ -1181,7 +1116,6 @@ public class HttpFields implements Iterable return bytes; } - /* ------------------------------------------------------------ */ private byte[] toSanitisedValue(String s) { byte[] bytes = s.getBytes(StringUtil.__ISO_8859_1_CHARSET); @@ -1197,7 +1131,6 @@ public class HttpFields implements Iterable return bytes; } - /* ------------------------------------------------------------ */ public void putTo(ByteBuffer bufferInFillMode) { HttpHeader header = HttpHeader.CACHE.get(_name); @@ -1226,50 +1159,42 @@ public class HttpFields implements Iterable BufferUtil.putCRLF(bufferInFillMode); } - /* ------------------------------------------------------------ */ public void putValueTo(ByteBuffer buffer) { buffer.put(toSanitisedValue(_value)); } - /* ------------------------------------------------------------ */ public HttpHeader getHeader() { return _header; } - /* ------------------------------------------------------------ */ public String getName() { return _name; } - /* ------------------------------------------------------------ */ public String getValue() { return _value; } - /* ------------------------------------------------------------ */ public int getIntValue() { return StringUtil.toInt(_value); } - /* ------------------------------------------------------------ */ public long getLongValue() { return StringUtil.toLong(_value); } - /* ------------------------------------------------------------ */ @Override public String toString() { return ("[" + getName() + "=" + _value + (_next == null ? "" : "->") + "]"); } - /* ------------------------------------------------------------ */ public boolean contains(String value) { if (_value==null) @@ -1292,7 +1217,6 @@ public class HttpFields implements Iterable } } - /* ------------------------------------------------------------ */ public boolean contains(HttpHeader header, String value) { Field field = getField(header); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java index d452296dac6..0d4889d7137 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.spdy.api; +import org.eclipse.jetty.util.Fields; + /** *

A container for HEADERS frame metadata and headers.

*/ @@ -40,16 +42,16 @@ public class HeadersInfo private final boolean close; private final boolean resetCompression; - private final Headers headers; + private final Fields headers; /** *

Creates a new {@link HeadersInfo} instance with the given headers, * the given close flag and no reset compression flag

* - * @param headers the {@link Headers} + * @param headers the {@link Fields} * @param close the value of the close flag */ - public HeadersInfo(Headers headers, boolean close) + public HeadersInfo(Fields headers, boolean close) { this(headers, close, false); } @@ -58,11 +60,11 @@ public class HeadersInfo *

Creates a new {@link HeadersInfo} instance with the given headers, * the given close flag and the given reset compression flag

* - * @param headers the {@link Headers} + * @param headers the {@link Fields} * @param close the value of the close flag * @param resetCompression the value of the reset compression flag */ - public HeadersInfo(Headers headers, boolean close, boolean resetCompression) + public HeadersInfo(Fields headers, boolean close, boolean resetCompression) { this.headers = headers; this.close = close; @@ -86,9 +88,9 @@ public class HeadersInfo } /** - * @return the {@link Headers} + * @return the {@link Fields} */ - public Headers getHeaders() + public Fields getHeaders() { return headers; } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java index 2bbd2ea9cab..12109af71a0 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.spdy.api; +import org.eclipse.jetty.util.Fields; + /** *

A container for SYN_REPLY frames metadata and headers.

*/ @@ -31,7 +33,7 @@ public class ReplyInfo */ public static final byte FLAG_CLOSE = 1; - private final Headers headers; + private final Fields headers; private final boolean close; /** @@ -41,25 +43,25 @@ public class ReplyInfo */ public ReplyInfo(boolean close) { - this(new Headers(), close); + this(new Fields(), close); } /** *

Creates a {@link ReplyInfo} instance with the given headers and the given close flag.

* - * @param headers the {@link Headers} + * @param headers the {@link Fields} * @param close the value of the close flag */ - public ReplyInfo(Headers headers, boolean close) + public ReplyInfo(Fields headers, boolean close) { this.headers = headers; this.close = close; } /** - * @return the {@link Headers} + * @return the {@link Fields} */ - public Headers getHeaders() + public Fields getHeaders() { return headers; } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java index 22b622ebcb4..20dafbaecdc 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.spdy.api; +import org.eclipse.jetty.util.Fields; + /** *

A container for SYN_STREAM frames metadata and data.

*/ @@ -33,7 +35,7 @@ public class SynInfo private final boolean close; private final byte priority; - private final Headers headers; + private final Fields headers; /** *

Creates a new {@link SynInfo} instance with empty headers and the given close flag, @@ -43,17 +45,17 @@ public class SynInfo */ public SynInfo(boolean close) { - this(new Headers(), close); + this(new Fields(), close); } /** *

Creates a {@link ReplyInfo} instance with the given headers and the given close flag, * not unidirectional, without associated stream, and with default priority.

* - * @param headers the {@link Headers} + * @param headers the {@link Fields} * @param close the value of the close flag */ - public SynInfo(Headers headers, boolean close) + public SynInfo(Fields headers, boolean close) { this(headers, close, (byte)0); } @@ -62,21 +64,21 @@ public class SynInfo *

* Creates a {@link ReplyInfo} instance with the given headers, the given close flag and with the given priority. *

- * + * * @param headers - * the {@link Headers} + * the {@link Fields} * @param close * the value of the close flag * @param priority * the priority */ - public SynInfo(Headers headers, boolean close, byte priority) + public SynInfo(Fields headers, boolean close, byte priority) { this.close = close; this.priority = priority; this.headers = headers; } - + /** * @return the value of the close flag */ @@ -94,13 +96,13 @@ public class SynInfo } /** - * @return the {@link Headers} + * @return the {@link Fields} */ - public Headers getHeaders() + public Fields getHeaders() { return headers; } - + /** * @return the close flag as integer * @see #FLAG_CLOSE diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java index 80bd3c0434a..a8c44e27de4 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java @@ -18,15 +18,15 @@ package org.eclipse.jetty.spdy.frames; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; +import org.eclipse.jetty.util.Fields; public class HeadersFrame extends ControlFrame { private final int streamId; - private final Headers headers; + private final Fields headers; - public HeadersFrame(short version, byte flags, int streamId, Headers headers) + public HeadersFrame(short version, byte flags, int streamId, Fields headers) { super(version, ControlFrameType.HEADERS, flags); this.streamId = streamId; @@ -38,7 +38,7 @@ public class HeadersFrame extends ControlFrame return streamId; } - public Headers getHeaders() + public Fields getHeaders() { return headers; } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java index edc139f5eef..51605d1394e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java @@ -18,15 +18,15 @@ package org.eclipse.jetty.spdy.frames; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; +import org.eclipse.jetty.util.Fields; public class SynReplyFrame extends ControlFrame { private final int streamId; - private final Headers headers; + private final Fields headers; - public SynReplyFrame(short version, byte flags, int streamId, Headers headers) + public SynReplyFrame(short version, byte flags, int streamId, Fields headers) { super(version, ControlFrameType.SYN_REPLY, flags); this.streamId = streamId; @@ -38,7 +38,7 @@ public class SynReplyFrame extends ControlFrame return streamId; } - public Headers getHeaders() + public Fields getHeaders() { return headers; } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java index ae06d951875..fd356865d29 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java @@ -19,8 +19,8 @@ package org.eclipse.jetty.spdy.frames; import org.eclipse.jetty.spdy.PushSynInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; public class SynStreamFrame extends ControlFrame { @@ -28,9 +28,9 @@ public class SynStreamFrame extends ControlFrame private final int associatedStreamId; private final byte priority; private final short slot; - private final Headers headers; + private final Fields headers; - public SynStreamFrame(short version, byte flags, int streamId, int associatedStreamId, byte priority, short slot, Headers headers) + public SynStreamFrame(short version, byte flags, int streamId, int associatedStreamId, byte priority, short slot, Fields headers) { super(version, ControlFrameType.SYN_STREAM, flags); this.streamId = streamId; @@ -60,7 +60,7 @@ public class SynStreamFrame extends ControlFrame return slot; } - public Headers getHeaders() + public Fields getHeaders() { return headers; } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java index 3f78d1a928d..30c3e50a8dc 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java @@ -24,8 +24,8 @@ import java.nio.charset.Charset; import org.eclipse.jetty.spdy.CompressionDictionary; import org.eclipse.jetty.spdy.CompressionFactory; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; +import org.eclipse.jetty.util.Fields; public class HeadersBlockGenerator { @@ -37,13 +37,13 @@ public class HeadersBlockGenerator this.compressor = compressor; } - public ByteBuffer generate(short version, Headers headers) + public ByteBuffer generate(short version, Fields headers) { // TODO: ByteArrayOutputStream is quite inefficient, but grows on demand; optimize using ByteBuffer ? Charset iso1 = Charset.forName("ISO-8859-1"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(headers.size() * 64); writeCount(version, buffer, headers.size()); - for (Headers.Header header : headers) + for (Fields.Field header : headers) { String name = header.name().toLowerCase(); byte[] nameBytes = name.getBytes(iso1); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java index 5335579640d..2152c95a42e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java @@ -21,15 +21,15 @@ package org.eclipse.jetty.spdy.parser; import java.nio.ByteBuffer; import org.eclipse.jetty.spdy.CompressionFactory; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.frames.ControlFrameType; import org.eclipse.jetty.spdy.frames.HeadersFrame; +import org.eclipse.jetty.util.Fields; public class HeadersBodyParser extends ControlFrameBodyParser { - private final Headers headers = new Headers(); + private final Fields headers = new Fields(); private final ControlFrameParser controlFrameParser; private final HeadersBlockParser headersBlockParser; private State state = State.STREAM_ID; @@ -126,7 +126,7 @@ public class HeadersBodyParser extends ControlFrameBodyParser if (flags != 0 && flags != HeadersInfo.FLAG_CLOSE && flags != HeadersInfo.FLAG_RESET_COMPRESSION) throw new IllegalArgumentException("Invalid flag " + flags + " for frame " + ControlFrameType.HEADERS); - HeadersFrame frame = new HeadersFrame(version, flags, streamId, new Headers(headers, true)); + HeadersFrame frame = new HeadersFrame(version, flags, streamId, new Fields(headers, true)); controlFrameParser.onControlFrame(frame); reset(); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java index 4d94e3d3fb1..f0ca24a3963 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java @@ -21,15 +21,15 @@ package org.eclipse.jetty.spdy.parser; import java.nio.ByteBuffer; import org.eclipse.jetty.spdy.CompressionFactory; -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.frames.ControlFrameType; import org.eclipse.jetty.spdy.frames.SynReplyFrame; +import org.eclipse.jetty.util.Fields; public class SynReplyBodyParser extends ControlFrameBodyParser { - private final Headers headers = new Headers(); + private final Fields headers = new Fields(); private final ControlFrameParser controlFrameParser; private final HeadersBlockParser headersBlockParser; private State state = State.STREAM_ID; @@ -124,7 +124,7 @@ public class SynReplyBodyParser extends ControlFrameBodyParser if (flags != 0 && flags != ReplyInfo.FLAG_CLOSE) throw new IllegalArgumentException("Invalid flag " + flags + " for frame " + ControlFrameType.SYN_REPLY); - SynReplyFrame frame = new SynReplyFrame(version, flags, streamId, new Headers(headers, true)); + SynReplyFrame frame = new SynReplyFrame(version, flags, streamId, new Fields(headers, true)); controlFrameParser.onControlFrame(frame); reset(); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java index 58dccf28424..ff883ccce97 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java @@ -23,16 +23,16 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.spdy.CompressionFactory; import org.eclipse.jetty.spdy.PushSynInfo; import org.eclipse.jetty.spdy.StreamException; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.StreamStatus; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.frames.ControlFrameType; import org.eclipse.jetty.spdy.frames.SynStreamFrame; +import org.eclipse.jetty.util.Fields; public class SynStreamBodyParser extends ControlFrameBodyParser { - private final Headers headers = new Headers(); + private final Fields headers = new Fields(); private final ControlFrameParser controlFrameParser; private final HeadersBlockParser headersBlockParser; private State state = State.STREAM_ID; @@ -139,7 +139,7 @@ public class SynStreamBodyParser extends ControlFrameBodyParser if (flags > (SynInfo.FLAG_CLOSE | PushSynInfo.FLAG_UNIDIRECTIONAL)) throw new IllegalArgumentException("Invalid flag " + flags + " for frame " + ControlFrameType.SYN_STREAM); - SynStreamFrame frame = new SynStreamFrame(version, flags, streamId, associatedStreamId, priority, slot, new Headers(headers, true)); + SynStreamFrame frame = new SynStreamFrame(version, flags, streamId, associatedStreamId, priority, slot, new Fields(headers, true)); controlFrameParser.onControlFrame(frame); reset(); diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java index c1897c0d33b..a2715d97c51 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java @@ -32,7 +32,6 @@ import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.StandardSession.FrameBytes; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.RstInfo; import org.eclipse.jetty.spdy.api.SPDY; @@ -47,6 +46,7 @@ import org.eclipse.jetty.spdy.frames.SynReplyFrame; import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.TimerScheduler; import org.junit.After; @@ -79,7 +79,7 @@ public class StandardSessionTest private StandardSession session; private Generator generator; private Scheduler scheduler; - private Headers headers; + private Fields headers; @Before public void setUp() throws Exception @@ -90,7 +90,7 @@ public class StandardSessionTest scheduler.start(); generator = new Generator(bufferPool, new StandardCompressionFactory.StandardCompressor()); session = new StandardSession(SPDY.V2,bufferPool,threadPool,scheduler,controller,null,1,null,generator,new FlowControlStrategy.None()); - headers = new Headers(); + headers = new Fields(); } @After diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java index 3624636df80..9c580fcb449 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.spdy.StandardSession; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.junit.Ignore; import org.junit.Test; @@ -119,7 +120,7 @@ public class ClientUsageTest public void onReply(Stream stream, ReplyInfo replyInfo) { // Do something with the response - Headers headers = replyInfo.getHeaders(); + Fields headers = replyInfo.getHeaders(); int contentLength = headers.get("content-length").valueAsInt(); stream.setAttribute("content-length", contentLength); if (!replyInfo.isClose()) diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java index 04e534ccb05..11ce76e47ca 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.junit.Ignore; import org.junit.Test; @@ -36,12 +37,12 @@ public class ServerUsageTest @Override public StreamFrameListener onSyn(Stream stream, SynInfo streamInfo) { - Headers synHeaders = streamInfo.getHeaders(); + Fields synHeaders = streamInfo.getHeaders(); // Do something with headers, for example extract them and // perform an http request via Jetty's LocalConnector // Get the http response, fill headers and data - Headers replyHeaders = new Headers(); + Fields replyHeaders = new Fields(); replyHeaders.put(synHeaders.get("host")); // Sends a reply stream.reply(new ReplyInfo(replyHeaders, false)); @@ -82,7 +83,7 @@ public class ServerUsageTest // the client sends a rst frame. // We have to atomically set some flag on the stream to signal it's closed // and any operation on it will throw - stream.headers(new HeadersInfo(new Headers(), true)); + stream.headers(new HeadersInfo(new Fields(), true)); } }); } @@ -102,7 +103,7 @@ public class ServerUsageTest Session session = stream.getSession(); // Since it's unidirectional, no need to pass the listener - session.syn(new SynInfo(new Headers(), false, (byte)0), null, 0, TimeUnit.MILLISECONDS, new Callback.Empty() + session.syn(new SynInfo(new Fields(), false, (byte)0), null, 0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(Stream pushStream) diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java index 8835456d672..bafab060abe 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java @@ -22,11 +22,11 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; +import org.eclipse.jetty.util.Fields; import org.junit.Before; import org.junit.Test; @@ -37,7 +37,7 @@ import static org.junit.Assert.assertThat; public class HeadersGenerateParseTest { - private Headers headers = new Headers(); + private Fields headers = new Fields(); private int streamId = 13; private byte flags = HeadersInfo.FLAG_RESET_COMPRESSION; private final TestSPDYParserListener listener = new TestSPDYParserListener(); @@ -52,7 +52,7 @@ public class HeadersGenerateParseTest buffer = createHeadersFrameBuffer(headers); } - private ByteBuffer createHeadersFrameBuffer(Headers headers) + private ByteBuffer createHeadersFrameBuffer(Fields headers) { HeadersFrame frame1 = new HeadersFrame(SPDY.V2, flags, streamId, headers); Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor()); @@ -80,15 +80,15 @@ public class HeadersGenerateParseTest @Test public void testHeadersAreTranslatedToLowerCase() { - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put("Via","localhost"); parser.parse(createHeadersFrameBuffer(headers)); HeadersFrame parsedHeadersFrame = assertExpectationsAreMet(headers); - Headers.Header viaHeader = parsedHeadersFrame.getHeaders().get("via"); + Fields.Field viaHeader = parsedHeadersFrame.getHeaders().get("via"); assertThat("Via Header name is lowercase", viaHeader.name(), is("via")); } - private HeadersFrame assertExpectationsAreMet(Headers headers) + private HeadersFrame assertExpectationsAreMet(Fields headers) { ControlFrame parsedControlFrame = listener.getControlFrame(); assertThat("listener received controlFrame", parsedControlFrame, notNullValue()); diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java index 3255b36a923..90ecc1d4e75 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java @@ -22,11 +22,11 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; -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.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -37,7 +37,7 @@ public class SynReplyGenerateParseTest { byte flags = ReplyInfo.FLAG_CLOSE; int streamId = 13; - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put("a", "b"); SynReplyFrame frame1 = new SynReplyFrame(SPDY.V2, flags, streamId, headers); Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor()); @@ -65,7 +65,7 @@ public class SynReplyGenerateParseTest { byte flags = ReplyInfo.FLAG_CLOSE; int streamId = 13; - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put("a", "b"); SynReplyFrame frame1 = new SynReplyFrame(SPDY.V2, flags, streamId, headers); Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor()); diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java index 22a1944abab..8a44b36e060 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java @@ -22,11 +22,11 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -40,7 +40,7 @@ public class SynStreamGenerateParseTest int associatedStreamId = 11; byte priority = 3; short slot = 5; - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put("a", "b"); headers.put("c", "d"); SynStreamFrame frame1 = new SynStreamFrame(SPDY.V2, flags, streamId, associatedStreamId, priority, slot, headers); @@ -75,7 +75,7 @@ public class SynStreamGenerateParseTest int associatedStreamId = 11; byte priority = 3; short slot = 5; - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put("a", "b"); headers.put("c", "d"); SynStreamFrame frame1 = new SynStreamFrame(SPDY.V2, flags, streamId, associatedStreamId, priority, slot, headers); diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java index 17dfc3150fb..0b33e00c374 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java @@ -26,13 +26,13 @@ import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.SessionException; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.StreamException; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.DataFrame; import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.spdy.generator.Generator; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -41,7 +41,7 @@ public class UnknownControlFrameTest @Test public void testUnknownControlFrame() throws Exception { - SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, new Headers()); + SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, new Fields()); Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor()); ByteBuffer buffer = generator.control(frame); // Change the frame type to unknown diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpChannelOverSPDY.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpChannelOverSPDY.java index a41ecde0bce..d69bbcd7738 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpChannelOverSPDY.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpChannelOverSPDY.java @@ -32,8 +32,8 @@ import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpTransport; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -97,13 +97,13 @@ public class HttpChannelOverSPDY extends HttpChannel } } - public void requestStart(final Headers headers, final boolean endRequest) + public void requestStart(final Fields headers, final boolean endRequest) { if (!headers.isEmpty()) requestHeaders(headers, endRequest); } - public void requestHeaders(Headers headers, boolean endRequest) + public void requestHeaders(Fields headers, boolean endRequest) { boolean proceed = performBeginRequest(headers); if (!proceed) @@ -155,12 +155,12 @@ public class HttpChannelOverSPDY extends HttpChannel } } - private boolean performBeginRequest(Headers headers) + private boolean performBeginRequest(Fields headers) { short version = stream.getSession().getVersion(); - Headers.Header methodHeader = headers.get(HTTPSPDYHeader.METHOD.name(version)); - Headers.Header uriHeader = headers.get(HTTPSPDYHeader.URI.name(version)); - Headers.Header versionHeader = headers.get(HTTPSPDYHeader.VERSION.name(version)); + Fields.Field methodHeader = headers.get(HTTPSPDYHeader.METHOD.name(version)); + Fields.Field uriHeader = headers.get(HTTPSPDYHeader.URI.name(version)); + Fields.Field versionHeader = headers.get(HTTPSPDYHeader.VERSION.name(version)); if (methodHeader == null || uriHeader == null || versionHeader == null) { @@ -175,15 +175,15 @@ public class HttpChannelOverSPDY extends HttpChannel LOG.debug("HTTP > {} {} {}", httpMethod, uriString, httpVersion); startRequest(httpMethod, httpMethod.asString(), uriString, httpVersion); - Headers.Header schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version)); + Fields.Field schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version)); if (schemeHeader != null) getRequest().setScheme(schemeHeader.value()); return true; } - private void performHeaders(Headers headers) + private void performHeaders(Fields headers) { - for (Headers.Header header : headers) + for (Fields.Field header : headers) { String name = header.name(); HttpHeader httpHeader = HttpHeader.CACHE.get(name); diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpTransportOverSPDY.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpTransportOverSPDY.java index 824481a5845..a74aa92d822 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpTransportOverSPDY.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HttpTransportOverSPDY.java @@ -32,13 +32,13 @@ import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpTransport; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; -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.Stream; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -51,9 +51,9 @@ public class HttpTransportOverSPDY implements HttpTransport private final EndPoint endPoint; private final PushStrategy pushStrategy; private final Stream stream; - private final Headers requestHeaders; + private final Fields requestHeaders; - public HttpTransportOverSPDY(Connector connector, HttpConfiguration configuration, EndPoint endPoint, PushStrategy pushStrategy, Stream stream, Headers requestHeaders) + public HttpTransportOverSPDY(Connector connector, HttpConfiguration configuration, EndPoint endPoint, PushStrategy pushStrategy, Stream stream, Fields requestHeaders) { this.connector = connector; this.configuration = configuration; @@ -67,7 +67,7 @@ public class HttpTransportOverSPDY implements HttpTransport public void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent) throws IOException { short version = stream.getSession().getVersion(); - Headers headers = new Headers(); + Fields headers = new Fields(); HttpVersion httpVersion = HttpVersion.HTTP_1_1; headers.put(HTTPSPDYHeader.VERSION.name(version), httpVersion.asString()); @@ -126,20 +126,20 @@ public class HttpTransportOverSPDY implements HttpTransport if (!stream.isUnidirectional()) stream.reply(replyInfo); - Headers responseHeaders = replyInfo.getHeaders(); + Fields responseHeaders = replyInfo.getHeaders(); short version = stream.getSession().getVersion(); if (responseHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().startsWith("200") && !stream.isClosed()) { // We have a 200 OK with some content to send, check the push strategy - Headers.Header scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)); - Headers.Header host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)); - Headers.Header uri = requestHeaders.get(HTTPSPDYHeader.URI.name(version)); + Fields.Field scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)); + Fields.Field host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)); + Fields.Field uri = requestHeaders.get(HTTPSPDYHeader.URI.name(version)); Set pushResources = pushStrategy.apply(stream, requestHeaders, responseHeaders); for (String pushResource : pushResources) { - Headers pushHeaders = createPushHeaders(scheme, host, pushResource); - final Headers pushRequestHeaders = createRequestHeaders(scheme, host, uri, pushResource); + Fields pushHeaders = createPushHeaders(scheme, host, pushResource); + final Fields pushRequestHeaders = createRequestHeaders(scheme, host, uri, pushResource); // TODO: handle the timeout better stream.syn(new SynInfo(pushHeaders, false), 0, TimeUnit.MILLISECONDS, new Callback.Empty() @@ -155,9 +155,9 @@ public class HttpTransportOverSPDY implements HttpTransport } } - private Headers createRequestHeaders(Headers.Header scheme, Headers.Header host, Headers.Header uri, String pushResourcePath) + private Fields createRequestHeaders(Fields.Field scheme, Fields.Field host, Fields.Field uri, String pushResourcePath) { - final Headers requestHeaders = new Headers(); + final Fields requestHeaders = new Fields(); short version = stream.getSession().getVersion(); requestHeaders.put(HTTPSPDYHeader.METHOD.name(version), "GET"); requestHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -172,9 +172,9 @@ public class HttpTransportOverSPDY implements HttpTransport return requestHeaders; } - private Headers createPushHeaders(Headers.Header scheme, Headers.Header host, String pushResourcePath) + private Fields createPushHeaders(Fields.Field scheme, Fields.Field host, String pushResourcePath) { - final Headers pushHeaders = new Headers(); + final Fields pushHeaders = new Fields(); short version = stream.getSession().getVersion(); if (version == SPDY.V2) pushHeaders.put(HTTPSPDYHeader.URI.name(version), scheme.value() + "://" + host.value() + pushResourcePath); @@ -189,7 +189,7 @@ public class HttpTransportOverSPDY implements HttpTransport return pushHeaders; } - private HttpChannelOverSPDY newHttpChannelOverSPDY(Stream pushStream, Headers pushRequestHeaders) + private HttpChannelOverSPDY newHttpChannelOverSPDY(Stream pushStream, Fields pushRequestHeaders) { HttpTransport transport = new HttpTransportOverSPDY(connector, configuration, endPoint, pushStrategy, pushStream, pushRequestHeaders); HttpInputOverSPDY input = new HttpInputOverSPDY(); diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java index b5d1a76f3a9..9be82d37451 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java @@ -22,8 +22,8 @@ package org.eclipse.jetty.spdy.http; import java.util.Collections; import java.util.Set; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.util.Fields; /** *

{@link PushStrategy} encapsulates the decisions about performing @@ -39,7 +39,7 @@ public interface PushStrategy * @param responseHeaders the primary resource response headers * @return a list of secondary resource URIs to push */ - public Set apply(Stream stream, Headers requestHeaders, Headers responseHeaders); + public Set apply(Stream stream, Fields requestHeaders, Fields responseHeaders); /** * An implementation that returns an empty list of secondary resources @@ -47,7 +47,7 @@ public interface PushStrategy public static class None implements PushStrategy { @Override - public Set apply(Stream stream, Headers requestHeaders, Headers responseHeaders) + public Set apply(Stream stream, Fields requestHeaders, Fields responseHeaders) { return Collections.emptySet(); } diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java index 73754e26a2e..1732997ffab 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java @@ -30,8 +30,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.regex.Pattern; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -119,7 +119,7 @@ public class ReferrerPushStrategy implements PushStrategy } @Override - public Set apply(Stream stream, Headers requestHeaders, Headers responseHeaders) + public Set apply(Stream stream, Fields requestHeaders, Fields responseHeaders) { Set result = Collections.emptySet(); short version = stream.getSession().getVersion(); @@ -138,7 +138,7 @@ public class ReferrerPushStrategy implements PushStrategy } else if (isPushResource(url, responseHeaders)) { - Headers.Header referrerHeader = requestHeaders.get("referer"); + Fields.Field referrerHeader = requestHeaders.get("referer"); if (referrerHeader != null) { String referrer = referrerHeader.value(); @@ -180,7 +180,7 @@ public class ReferrerPushStrategy implements PushStrategy return mainResource; } - private boolean isIfModifiedSinceHeaderPresent(Headers headers) + private boolean isIfModifiedSinceHeaderPresent(Fields headers) { return headers.get("if-modified-since") != null; } @@ -190,18 +190,18 @@ public class ReferrerPushStrategy implements PushStrategy return "GET".equalsIgnoreCase(method); } - private boolean isMainResource(String url, Headers responseHeaders) + private boolean isMainResource(String url, Fields responseHeaders) { return !isPushResource(url, responseHeaders); } - private boolean isPushResource(String url, Headers responseHeaders) + private boolean isPushResource(String url, Fields responseHeaders) { for (Pattern pushRegexp : pushRegexps) { if (pushRegexp.matcher(url).matches()) { - Headers.Header header = responseHeaders.get("content-type"); + Fields.Field header = responseHeaders.get("content-type"); if (header == null) return true; diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYConnectionFactory.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYConnectionFactory.java index cc4232b5c60..c4f499523c5 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYConnectionFactory.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYConnectionFactory.java @@ -27,13 +27,13 @@ import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.spdy.ServerSPDYConnectionFactory; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Scheduler; @@ -81,7 +81,7 @@ public class ServerHTTPSPDYConnectionFactory extends ServerSPDYConnectionFactory logger.debug("Received {} on {}", synInfo, stream); - Headers headers = synInfo.getHeaders(); + Fields headers = synInfo.getHeaders(); HttpTransportOverSPDY transport = new HttpTransportOverSPDY(connector, configuration, endPoint, pushStrategy, stream, headers); HttpInputOverSPDY input = new HttpInputOverSPDY(); HttpChannelOverSPDY channel = new HttpChannelOverSPDY(connector, configuration, endPoint, transport, input, stream); diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java index f2d90e09430..be24ec48d5f 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java @@ -23,10 +23,10 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -71,7 +71,7 @@ public abstract class ProxyEngine return name; } - protected void addRequestProxyHeaders(Stream stream, Headers headers) + protected void addRequestProxyHeaders(Stream stream, Fields headers) { addViaHeader(headers); InetSocketAddress address = (InetSocketAddress)stream.getSession().getAttribute("org.eclipse.jetty.spdy.remoteAddress"); @@ -79,21 +79,21 @@ public abstract class ProxyEngine headers.add("X-Forwarded-For", address.getHostName()); } - protected void addResponseProxyHeaders(Stream stream, Headers headers) + protected void addResponseProxyHeaders(Stream stream, Fields headers) { addViaHeader(headers); } - private void addViaHeader(Headers headers) + private void addViaHeader(Fields headers) { headers.add("Via", "http/1.1 " + getName()); } - protected void customizeRequestHeaders(Stream stream, Headers headers) + protected void customizeRequestHeaders(Stream stream, Fields headers) { } - protected void customizeResponseHeaders(Stream stream, Headers headers) + protected void customizeResponseHeaders(Stream stream, Fields headers) { } diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java index 7dd0887e509..e74fbbd168c 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.PingInfo; import org.eclipse.jetty.spdy.api.RstInfo; import org.eclipse.jetty.spdy.api.Session; @@ -34,6 +33,7 @@ import org.eclipse.jetty.spdy.api.StreamStatus; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -60,9 +60,9 @@ public class ProxyEngineSelector extends ServerSessionFrameListener.Adapter final Session clientSession = clientStream.getSession(); short clientVersion = clientSession.getVersion(); - Headers headers = new Headers(clientSynInfo.getHeaders(), false); + Fields headers = new Fields(clientSynInfo.getHeaders(), false); - Headers.Header hostHeader = headers.get(HTTPSPDYHeader.HOST.name(clientVersion)); + Fields.Field hostHeader = headers.get(HTTPSPDYHeader.HOST.name(clientVersion)); if (hostHeader == null) { logger.debug("No host header found: " + headers); diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYConnection.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYConnection.java index b404e95c031..91c4b18263f 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYConnection.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYConnection.java @@ -41,7 +41,6 @@ import org.eclipse.jetty.spdy.StandardStream; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; @@ -51,11 +50,12 @@ import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParser.RequestHandler { private final short version; - private final Headers headers = new Headers(); + private final Fields headers = new Fields(); private final ProxyEngineSelector proxyEngineSelector; private final ISession session; private HTTPStream stream; @@ -230,7 +230,7 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse { try { - Headers headers = new Headers(replyInfo.getHeaders(), false); + Fields headers = new Fields(replyInfo.getHeaders(), false); headers.remove(HTTPSPDYHeader.SCHEME.name(version)); @@ -243,12 +243,12 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse HttpVersion httpVersion = HttpVersion.fromString(headers.remove(HTTPSPDYHeader.VERSION.name(version)).value()); // Convert the Host header from a SPDY special header to a normal header - Headers.Header host = headers.remove(HTTPSPDYHeader.HOST.name(version)); + Fields.Field host = headers.remove(HTTPSPDYHeader.HOST.name(version)); if (host != null) headers.put("host", host.value()); HttpFields fields = new HttpFields(); - for (Headers.Header header : headers) + for (Fields.Field header : headers) { String name = camelize(header.name()); fields.put(name, header.value()); diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java index 693dac9141e..de7e6851965 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java @@ -30,7 +30,6 @@ import org.eclipse.jetty.spdy.SPDYClient; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; @@ -43,6 +42,7 @@ import org.eclipse.jetty.spdy.api.StreamStatus; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; /** *

{@link SPDYProxyEngine} implements a SPDY to SPDY proxy, that is, converts SPDY events received by @@ -86,7 +86,7 @@ public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener public StreamFrameListener proxy(final Stream clientStream, SynInfo clientSynInfo, ProxyEngineSelector.ProxyServerInfo proxyServerInfo) { - Headers headers = new Headers(clientSynInfo.getHeaders(), false); + Fields headers = new Fields(clientSynInfo.getHeaders(), false); short serverVersion = getVersion(proxyServerInfo.getProtocol()); InetSocketAddress address = proxyServerInfo.getAddress(); @@ -182,13 +182,13 @@ public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener } } - private void convert(short fromVersion, short toVersion, Headers headers) + private void convert(short fromVersion, short toVersion, Fields headers) { if (fromVersion != toVersion) { for (HTTPSPDYHeader httpHeader : HTTPSPDYHeader.values()) { - Headers.Header header = headers.remove(httpHeader.name(fromVersion)); + Fields.Field header = headers.remove(httpHeader.name(fromVersion)); if (header != null) { String toName = httpHeader.name(toVersion); @@ -221,7 +221,7 @@ public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener logger.debug("S -> P {} on {}", replyInfo, stream); short serverVersion = stream.getSession().getVersion(); - Headers headers = new Headers(replyInfo.getHeaders(), false); + Fields headers = new Fields(replyInfo.getHeaders(), false); addResponseProxyHeaders(stream, headers); customizeResponseHeaders(stream, headers); @@ -449,7 +449,7 @@ public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener { logger.debug("S -> P pushed {} on {}", serverSynInfo, serverStream); - Headers headers = new Headers(serverSynInfo.getHeaders(), false); + Fields headers = new Fields(serverSynInfo.getHeaders(), false); addResponseProxyHeaders(serverStream, headers); customizeResponseHeaders(serverStream, headers); diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java index e4c3153a2b2..fb8fe43f340 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java @@ -27,12 +27,12 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -79,7 +79,7 @@ public class ConcurrentStreamsTest extends AbstractHTTPSPDYTest }), null); // Perform slow request. This will wait on server side until the fast request wakes it up - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/slow"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -90,7 +90,7 @@ public class ConcurrentStreamsTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); slowClientLatch.countDown(); } @@ -108,7 +108,7 @@ public class ConcurrentStreamsTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); fastClientLatch.countDown(); } diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java index ab75205c370..b097bbb8a18 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java @@ -36,13 +36,13 @@ import junit.framework.Assert; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Headers; 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; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; import org.junit.Ignore; @Ignore // TODO: update when jetty client is available @@ -215,7 +215,7 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest String primaryPath = "/" + j + ".html"; String referrer = new StringBuilder("http://localhost:").append(connector.getLocalPort()).append(primaryPath).toString(); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), primaryPath); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -270,10 +270,10 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest return result; } - private Headers createRequestHeaders(String referrer, String path) + private Fields createRequestHeaders(String referrer, String path) { - Headers headers; - headers = new Headers(); + Fields headers; + headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), path); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyTest.java index 7c32b34546f..14d5bba2c94 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyTest.java @@ -32,7 +32,6 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; 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; @@ -40,6 +39,7 @@ import org.eclipse.jetty.spdy.api.SessionFrameListener; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -73,7 +73,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest ConnectionFactory defaultFactory = new ServerHTTPSPDYConnectionFactory(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); connector.setDefaultConnectionFactory(defaultFactory); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); Session session1 = sendMainRequestAndCSSRequest(address, mainRequestHeaders); // Sleep for pushPeriod This should prevent application.js from being mapped as pushResource @@ -96,7 +96,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); connector.setDefaultConnectionFactory(defaultFactory); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); Session session1 = sendMainRequestAndCSSRequest(address, mainRequestHeaders); // Sleep for pushPeriod This should prevent application.js from being mapped as pushResource @@ -118,7 +118,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); connector.setDefaultConnectionFactory(defaultFactory); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); Session session1 = sendMainRequestAndCSSRequest(address, mainRequestHeaders); sendJSRequest(session1); @@ -146,7 +146,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest }); } - private Session sendMainRequestAndCSSRequest(InetSocketAddress address, Headers mainRequestHeaders) throws Exception + private Session sendMainRequestAndCSSRequest(InetSocketAddress address, Fields mainRequestHeaders) throws Exception { Session session1 = startClient(version, address, null); @@ -164,7 +164,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch1 = new CountDownLatch(1); - Headers associatedRequestHeaders1 = createHeaders(cssResource); + Fields associatedRequestHeaders1 = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders1, true), new StreamFrameListener.Adapter() { @Override @@ -184,7 +184,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest { final CountDownLatch associatedResourceLatch2 = new CountDownLatch(1); String jsResource = "/application.js"; - Headers associatedRequestHeaders2 = createHeaders(jsResource); + Fields associatedRequestHeaders2 = createHeaders(jsResource); session1.syn(new SynInfo(associatedRequestHeaders2, true), new StreamFrameListener.Adapter() { @Override @@ -198,7 +198,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertTrue(associatedResourceLatch2.await(5, TimeUnit.SECONDS)); } - private void run2ndClientRequests(InetSocketAddress address, Headers mainRequestHeaders, final boolean validateHeaders) throws Exception + private void run2ndClientRequests(InetSocketAddress address, Fields mainRequestHeaders, final boolean validateHeaders) throws Exception { // Create another client, and perform the same request for the main resource, // we expect the css being pushed, but not the js @@ -273,7 +273,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Session session1 = startClient(version, address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -288,7 +288,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = createHeaders(cssResource); + Fields associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -377,7 +377,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Session session1 = startClient(version, address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -393,7 +393,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest final CountDownLatch associatedResourceLatch = new CountDownLatch(1); String cssResource = "/stylesheet.css"; - Headers associatedRequestHeaders = createHeaders(cssResource); + Fields associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -407,7 +407,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertTrue(associatedResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch fakeAssociatedResourceLatch = new CountDownLatch(1); - Headers fakeAssociatedRequestHeaders = createHeaders(fakeResource); + Fields fakeAssociatedRequestHeaders = createHeaders(fakeResource); session1.syn(new SynInfo(fakeAssociatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -488,7 +488,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Session session1 = startClient(version, address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -503,7 +503,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = createHeaders(cssResource); + Fields associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -518,7 +518,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest final CountDownLatch nestedResourceLatch = new CountDownLatch(1); String imageUrl = "/image.gif"; - Headers nestedRequestHeaders = createHeaders(imageUrl, cssResource); + Fields nestedRequestHeaders = createHeaders(imageUrl, cssResource); session1.syn(new SynInfo(nestedRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -594,7 +594,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Session session1 = startClient(version, address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Fields mainRequestHeaders = createHeadersWithoutReferrer(mainResource); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -610,7 +610,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest final CountDownLatch associatedResourceLatch = new CountDownLatch(1); String associatedResource = "/home.html"; - Headers associatedRequestHeaders = createHeaders(associatedResource); + Fields associatedRequestHeaders = createHeaders(associatedResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -679,7 +679,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Session session1 = startClient(version, address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = createHeaders(mainResource); + Fields mainRequestHeaders = createHeaders(mainResource); mainRequestHeaders.put("If-Modified-Since", "Tue, 27 Mar 2012 16:36:52 GMT"); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -694,7 +694,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = createHeaders(cssResource); + Fields associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -752,7 +752,7 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest Assert.assertFalse("We don't expect data to be pushed as the main request contained an if-modified-since header",pushDataLatch.await(1, TimeUnit.SECONDS)); } - private void validateHeaders(Headers headers, CountDownLatch pushSynHeadersValid) + private void validateHeaders(Fields headers, CountDownLatch pushSynHeadersValid) { if (validateHeader(headers, HTTPSPDYHeader.STATUS.name(version), "200") && validateHeader(headers, HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1") @@ -760,18 +760,18 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest pushSynHeadersValid.countDown(); } - private boolean validateHeader(Headers headers, String name, String expectedValue) + private boolean validateHeader(Fields headers, String name, String expectedValue) { - Headers.Header header = headers.get(name); + Fields.Field header = headers.get(name); if (header != null && expectedValue.equals(header.value())) return true; System.out.println(name + " not valid! " + headers); return false; } - private boolean validateUriHeader(Headers headers) + private boolean validateUriHeader(Fields headers) { - Headers.Header uriHeader = headers.get(HTTPSPDYHeader.URI.name(version)); + Fields.Field uriHeader = headers.get(HTTPSPDYHeader.URI.name(version)); if (uriHeader != null) if (version == SPDY.V2 && uriHeader.value().startsWith("http://")) return true; @@ -782,21 +782,21 @@ public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest return false; } - private Headers createHeaders(String resource) + private Fields createHeaders(String resource) { return createHeaders(resource, mainResource); } - private Headers createHeaders(String resource, String referrer) + private Fields createHeaders(String resource, String referrer) { - Headers associatedRequestHeaders = createHeadersWithoutReferrer(resource); + Fields associatedRequestHeaders = createHeadersWithoutReferrer(resource); associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + referrer); return associatedRequestHeaders; } - private Headers createHeadersWithoutReferrer(String resource) + private Fields createHeadersWithoutReferrer(String resource) { - Headers associatedRequestHeaders = new Headers(); + Fields associatedRequestHeaders = new Fields(); associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version), "GET"); associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version), resource); associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java index ed7dcf040ce..641b7407d30 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java @@ -20,10 +20,10 @@ package org.eclipse.jetty.spdy.http; import java.util.Set; -import org.eclipse.jetty.spdy.api.Headers; 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.util.Fields; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -61,7 +61,7 @@ public class ReferrerPushStrategyUnitTest @Test public void testReferrerCallsAfterTimeoutAreNotAddedAsPushResources() throws InterruptedException { - Headers requestHeaders = getBaseHeaders(VERSION); + Fields requestHeaders = getBaseHeaders(VERSION); int referrerCallTimeout = 1000; referrerPushStrategy.setReferrerPushPeriod(referrerCallTimeout); setMockExpectations(); @@ -74,18 +74,18 @@ public class ReferrerPushStrategyUnitTest requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), "image2.jpg"); requestHeaders.put("referer", referrerUrl); - pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Fields()); assertThat("pushResources is empty", pushResources.size(), is(0)); requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), MAIN_URI); - pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Fields()); // as the image2.jpg request has been a link and not a subresource, we expect that pushResources.size() is still 2 assertThat("pushResources contains two elements image.jpg and style.css", pushResources.size(), is(2)); } - private Headers getBaseHeaders(short version) + private Fields getBaseHeaders(short version) { - Headers requestHeaders = new Headers(); + Fields requestHeaders = new Fields(); requestHeaders.put(HTTPSPDYHeader.SCHEME.name(version), SCHEME); requestHeaders.put(HTTPSPDYHeader.HOST.name(version), HOST); requestHeaders.put(HTTPSPDYHeader.URI.name(version), MAIN_URI); @@ -99,9 +99,9 @@ public class ReferrerPushStrategyUnitTest when(session.getVersion()).thenReturn(VERSION); } - private String fillPushStrategyCache(Headers requestHeaders) + private String fillPushStrategyCache(Fields requestHeaders) { - Set pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + Set pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Fields()); assertThat("pushResources is empty", pushResources.size(), is(0)); String origin = SCHEME + "://" + HOST; @@ -109,15 +109,15 @@ public class ReferrerPushStrategyUnitTest requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), "image.jpg"); requestHeaders.put("referer", referrerUrl); - pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Fields()); assertThat("pushResources is empty", pushResources.size(), is(0)); requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), "style.css"); - pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Fields()); assertThat("pushResources is empty", pushResources.size(), is(0)); requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), MAIN_URI); - pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Fields()); assertThat("pushResources contains two elements image.jpg and style.css", pushResources.size(), is(2)); return referrerUrl; } diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java index be993ff6105..43b828bef78 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java @@ -28,12 +28,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.jetty.spdy.SPDYClient; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Assert; import org.junit.Assume; @@ -75,7 +75,7 @@ public class SSLExternalServerTest extends AbstractHTTPSPDYTest } Session session = startClient(version, address, null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.SCHEME.name(version), "https"); headers.put(HTTPSPDYHeader.HOST.name(version), host + ":" + port); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); @@ -87,8 +87,8 @@ public class SSLExternalServerTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers headers = replyInfo.getHeaders(); - Headers.Header versionHeader = headers.get(HTTPSPDYHeader.STATUS.name(version)); + Fields headers = replyInfo.getHeaders(); + Fields.Field versionHeader = headers.get(HTTPSPDYHeader.STATUS.name(version)); if (versionHeader != null) { Matcher matcher = Pattern.compile("(\\d{3}).*").matcher(versionHeader.value()); diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java index 786cffe90f4..edebfd9cac5 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java @@ -40,13 +40,13 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; 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.Session; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -78,7 +78,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), path); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -91,7 +91,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -122,7 +122,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), uri); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -135,7 +135,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -163,7 +163,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "HEAD"); headers.put(HTTPSPDYHeader.URI.name(version), path); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -176,7 +176,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -213,7 +213,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), path); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -227,7 +227,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -259,7 +259,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), path); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -273,7 +273,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -308,7 +308,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), path); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -322,7 +322,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.toString(), replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -354,7 +354,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -368,7 +368,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -405,7 +405,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -419,7 +419,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -461,7 +461,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -479,7 +479,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest { Assert.assertEquals(1, replyFrames.incrementAndGet()); Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -521,7 +521,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -537,7 +537,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -579,7 +579,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -595,7 +595,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -637,7 +637,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -653,7 +653,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -700,7 +700,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -716,7 +716,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -758,7 +758,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -774,7 +774,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest { Assert.assertEquals(1, replies.incrementAndGet()); Assert.assertTrue(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("302")); Assert.assertTrue(replyHeaders.get("location").value().endsWith(suffix)); replyLatch.countDown(); @@ -800,7 +800,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -817,7 +817,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest { Assert.assertEquals(1, replies.incrementAndGet()); Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("404")); replyLatch.countDown(); } @@ -847,7 +847,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -863,7 +863,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertEquals(1, replies.incrementAndGet()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("500")); replyLatch.countDown(); if (replyInfo.isClose()) @@ -904,7 +904,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -922,7 +922,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest { Assert.assertEquals(1, replyFrames.incrementAndGet()); Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); Assert.assertTrue(replyHeaders.get("extra").value().contains("X")); replyLatch.countDown(); @@ -991,7 +991,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -1009,7 +1009,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest { Assert.assertEquals(1, replyFrames.incrementAndGet()); Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -1052,7 +1052,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -1067,7 +1067,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest public void onReply(Stream stream, ReplyInfo replyInfo) { Assert.assertFalse(replyInfo.isClose()); - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -1125,7 +1125,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -1137,7 +1137,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -1188,7 +1188,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -1200,7 +1200,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); replyLatch.countDown(); } @@ -1261,7 +1261,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -1273,7 +1273,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); responseLatch.countDown(); } @@ -1307,7 +1307,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } }), null); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); @@ -1319,7 +1319,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers replyHeaders = replyInfo.getHeaders(); + Fields replyHeaders = replyInfo.getHeaders(); Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); responseLatch.countDown(); } diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYTest.java index 509edb72ea7..2753496fd4b 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYTest.java @@ -37,7 +37,6 @@ import org.eclipse.jetty.spdy.ServerSPDYConnectionFactory; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.PingInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; @@ -51,6 +50,7 @@ import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -154,7 +154,7 @@ public class ProxyHTTPSPDYTest @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); responseHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200 OK"); stream.reply(new ReplyInfo(responseHeaders, true)); @@ -202,10 +202,10 @@ public class ProxyHTTPSPDYTest public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { Assert.assertTrue(synInfo.isClose()); - Headers requestHeaders = synInfo.getHeaders(); + Fields requestHeaders = synInfo.getHeaders(); Assert.assertNotNull(requestHeaders.get("via")); - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); responseHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200 OK"); ReplyInfo replyInfo = new ReplyInfo(responseHeaders, true); @@ -263,10 +263,10 @@ public class ProxyHTTPSPDYTest public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { Assert.assertTrue(synInfo.isClose()); - Headers requestHeaders = synInfo.getHeaders(); + Fields requestHeaders = synInfo.getHeaders(); Assert.assertNotNull(requestHeaders.get("via")); - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); responseHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200 OK"); ReplyInfo replyInfo = new ReplyInfo(responseHeaders, false); @@ -330,7 +330,7 @@ public class ProxyHTTPSPDYTest dataInfo.consume(dataInfo.length()); if (dataInfo.isClose()) { - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); headers.put(HTTPSPDYHeader.STATUS.name(version), "303 See Other"); stream.reply(new ReplyInfo(headers, true)); @@ -393,7 +393,7 @@ public class ProxyHTTPSPDYTest dataInfo.consume(dataInfo.length()); if (dataInfo.isClose()) { - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); responseHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200 OK"); ReplyInfo replyInfo = new ReplyInfo(responseHeaders, false); @@ -454,11 +454,11 @@ public class ProxyHTTPSPDYTest @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { - Headers requestHeaders = synInfo.getHeaders(); + Fields requestHeaders = synInfo.getHeaders(); Assert.assertNotNull(requestHeaders.get("via")); Assert.assertNotNull(requestHeaders.get(header)); - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(header, "baz"); stream.reply(new ReplyInfo(responseHeaders, true)); return null; @@ -469,7 +469,7 @@ public class ProxyHTTPSPDYTest Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS); final CountDownLatch replyLatch = new CountDownLatch(1); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort()); headers.put(header, "bar"); client.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() @@ -477,7 +477,7 @@ public class ProxyHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers headers = replyInfo.getHeaders(); + Fields headers = replyInfo.getHeaders(); Assert.assertNotNull(headers.get(header)); replyLatch.countDown(); } @@ -498,11 +498,11 @@ public class ProxyHTTPSPDYTest @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { - Headers requestHeaders = synInfo.getHeaders(); + Fields requestHeaders = synInfo.getHeaders(); Assert.assertNotNull(requestHeaders.get("via")); Assert.assertNotNull(requestHeaders.get(header)); - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(header, "baz"); stream.reply(new ReplyInfo(responseHeaders, false)); stream.data(new BytesDataInfo(data, true)); @@ -515,7 +515,7 @@ public class ProxyHTTPSPDYTest final CountDownLatch replyLatch = new CountDownLatch(1); final CountDownLatch dataLatch = new CountDownLatch(1); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort()); headers.put(header, "bar"); client.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() @@ -525,7 +525,7 @@ public class ProxyHTTPSPDYTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers headers = replyInfo.getHeaders(); + Fields headers = replyInfo.getHeaders(); Assert.assertNotNull(headers.get(header)); replyLatch.countDown(); } @@ -557,11 +557,11 @@ public class ProxyHTTPSPDYTest @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); responseHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200 OK"); - Headers pushHeaders = new Headers(); + Fields pushHeaders = new Fields(); pushHeaders.put(HTTPSPDYHeader.URI.name(version), "/push"); stream.syn(new SynInfo(pushHeaders, false), 5, TimeUnit.SECONDS, new Callback.Empty() { @@ -609,12 +609,12 @@ public class ProxyHTTPSPDYTest @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { - Headers responseHeaders = new Headers(); + Fields responseHeaders = new Fields(); responseHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); responseHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200 OK"); stream.reply(new ReplyInfo(responseHeaders, false)); - Headers pushHeaders = new Headers(); + Fields pushHeaders = new Fields(); pushHeaders.put(HTTPSPDYHeader.URI.name(version), "/push"); stream.syn(new SynInfo(pushHeaders, false), 5, TimeUnit.SECONDS, new Callback.Empty() { @@ -653,7 +653,7 @@ public class ProxyHTTPSPDYTest } }).get(5, TimeUnit.SECONDS); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort()); final CountDownLatch replyLatch = new CountDownLatch(1); final CountDownLatch dataLatch = new CountDownLatch(1); @@ -717,7 +717,7 @@ public class ProxyHTTPSPDYTest public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { Assert.assertTrue(synInfo.isClose()); - Headers requestHeaders = synInfo.getHeaders(); + Fields requestHeaders = synInfo.getHeaders(); Assert.assertNotNull(requestHeaders.get("via")); stream.getSession().rst(new RstInfo(stream.getId(), StreamStatus.REFUSED_STREAM)); @@ -753,7 +753,7 @@ public class ProxyHTTPSPDYTest public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { Assert.assertTrue(synInfo.isClose()); - Headers requestHeaders = synInfo.getHeaders(); + Fields requestHeaders = synInfo.getHeaders(); Assert.assertNotNull(requestHeaders.get("via")); stream.getSession().rst(new RstInfo(stream.getId(), StreamStatus.REFUSED_STREAM)); @@ -773,7 +773,7 @@ public class ProxyHTTPSPDYTest } }).get(5, TimeUnit.SECONDS); - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort()); client.syn(new SynInfo(headers, true), null); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java index 116fdda0bca..65a1edce603 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java @@ -30,7 +30,6 @@ import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -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; @@ -48,6 +47,7 @@ import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; import org.eclipse.jetty.spdy.parser.Parser.Listener; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -85,7 +85,7 @@ public class ClosedStreamTest extends AbstractTest Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor()); - ByteBuffer writeBuffer = generator.control(new SynReplyFrame(SPDY.V2, (byte)0, streamId, new Headers())); + ByteBuffer writeBuffer = generator.control(new SynReplyFrame(SPDY.V2, (byte)0, streamId, new Fields())); channel.write(writeBuffer); Assert.assertThat(writeBuffer.hasRemaining(), is(false)); @@ -216,7 +216,7 @@ public class ClosedStreamTest extends AbstractTest final Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor()); int streamId = 1; - ByteBuffer synData = generator.control(new SynStreamFrame(version,SynInfo.FLAG_CLOSE, streamId,0,(byte)0,(short)0,new Headers())); + ByteBuffer synData = generator.control(new SynStreamFrame(version,SynInfo.FLAG_CLOSE, streamId,0,(byte)0,(short)0,new Fields())); final SocketChannel socketChannel = SocketChannel.open(startServer); socketChannel.write(synData); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java index 9f874c0daec..a86ffbb3c3b 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java @@ -22,7 +22,6 @@ package org.eclipse.jetty.spdy; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.Session; @@ -30,6 +29,7 @@ import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -50,7 +50,7 @@ public class HeadersTest extends AbstractTest public void onHeaders(Stream stream, HeadersInfo headersInfo) { Assert.assertTrue(stream.isHalfClosed()); - stream.headers(new HeadersInfo(new Headers(), true)); + stream.headers(new HeadersInfo(new Fields(), true)); Assert.assertTrue(stream.isClosed()); } }; @@ -65,7 +65,7 @@ public class HeadersTest extends AbstractTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { - Headers headers = new Headers(); + Fields headers = new Fields(); headers.put("foo", "bar"); headers.put("baz", "woo"); stream.headers(new HeadersInfo(headers, true)); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java index 7bdc7a4664f..302a2ffbffb 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java @@ -28,7 +28,6 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.io.MappedByteBufferPool; 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.HeadersInfo; import org.eclipse.jetty.spdy.api.RstInfo; import org.eclipse.jetty.spdy.api.SPDY; @@ -43,6 +42,7 @@ import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.spdy.frames.ControlFrameType; import org.eclipse.jetty.spdy.frames.SynReplyFrame; import org.eclipse.jetty.spdy.generator.Generator; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -131,7 +131,7 @@ public class ProtocolViolationsTest extends AbstractTest { Session session = startClient(startServer(null), null); Stream stream = session.syn(new SynInfo(true), null).get(5, TimeUnit.SECONDS); - stream.headers(new HeadersInfo(new Headers(), true)); + stream.headers(new HeadersInfo(new Fields(), true)); } @Test //TODO: throws an ISException in StandardStream.updateCloseState(). But instead we should send a rst or something to the server probably?! @@ -159,7 +159,7 @@ public class ProtocolViolationsTest extends AbstractTest Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor()); - ByteBuffer writeBuffer = generator.control(new SynReplyFrame(SPDY.V2, (byte)0, streamId, new Headers())); + ByteBuffer writeBuffer = generator.control(new SynReplyFrame(SPDY.V2, (byte)0, streamId, new Fields())); channel.write(writeBuffer); assertThat("SynReply is fully written", writeBuffer.hasRemaining(), is(false)); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java index b1f36d6c320..01967c3c925 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java @@ -37,7 +37,6 @@ import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; import org.eclipse.jetty.spdy.api.SPDY; @@ -60,6 +59,7 @@ import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; import org.eclipse.jetty.spdy.parser.Parser.Listener; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -418,7 +418,7 @@ public class PushStreamTest extends AbstractTest final SocketChannel channel = SocketChannel.open(serverAddress); final Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor()); int streamId = 1; - ByteBuffer writeBuffer = generator.control(new SynStreamFrame(version,(byte)0,streamId,0,(byte)0,(short)0,new Headers())); + ByteBuffer writeBuffer = generator.control(new SynStreamFrame(version,(byte)0,streamId,0,(byte)0,(short)0,new Fields())); channel.write(writeBuffer); assertThat("writeBuffer is fully written",writeBuffer.hasRemaining(), is(false)); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java index 9d0c2d41223..cc64ce56cc4 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java @@ -34,7 +34,6 @@ import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; 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.Session; import org.eclipse.jetty.spdy.api.Stream; @@ -43,6 +42,7 @@ import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -73,7 +73,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest final int iterations = 500; final int count = 50; - final Headers headers = new Headers(); + final Fields headers = new Fields(); headers.put("method", "get"); headers.put("url", "/"); headers.put("version", "http/1.1"); @@ -142,7 +142,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest threadPool.shutdown(); } - private void synCompletedData(Session session, Headers headers, int iterations) throws Exception + private void synCompletedData(Session session, Fields headers, int iterations) throws Exception { final Map counter = new ConcurrentHashMap<>(iterations); final CountDownLatch latch = new CountDownLatch(2 * iterations); @@ -185,7 +185,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest Assert.assertTrue(counter.toString(), counter.isEmpty()); } - private void synGetDataGet(Session session, Headers headers, int iterations) throws Exception + private void synGetDataGet(Session session, Fields headers, int iterations) throws Exception { final Map counter = new ConcurrentHashMap<>(iterations); final CountDownLatch latch = new CountDownLatch(2 * iterations); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java index 3e175c1f6de..ae440a0b5f2 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicReference; 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.Session; import org.eclipse.jetty.spdy.api.SessionFrameListener; @@ -39,6 +38,7 @@ import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -63,7 +63,7 @@ public class SynReplyTest extends AbstractTest public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { Assert.assertTrue(stream.isHalfClosed()); - stream.reply(new ReplyInfo(new Headers(), true)); + stream.reply(new ReplyInfo(new Fields(), true)); synLatch.countDown(); return null; } @@ -93,7 +93,7 @@ public class SynReplyTest extends AbstractTest }); final CountDownLatch replyLatch = new CountDownLatch(1); - Stream stream = session.syn(new SynInfo(new Headers(), true), new StreamFrameListener.Adapter() + Stream stream = session.syn(new SynInfo(new Fields(), true), new StreamFrameListener.Adapter() { @Override public void onReply(Stream stream, ReplyInfo replyInfo) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java index 096fda59002..b7fc238d40b 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java @@ -25,7 +25,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.io.MappedByteBufferPool; -import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; @@ -38,6 +37,7 @@ import org.eclipse.jetty.spdy.frames.RstStreamFrame; import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; +import org.eclipse.jetty.util.Fields; import org.junit.Assert; import org.junit.Test; @@ -63,7 +63,7 @@ public class UnsupportedVersionTest extends AbstractTest } }); - SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, new Headers()); + SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, new Fields()); Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor()); ByteBuffer buffer = generator.control(frame); // Replace the version byte with an unsupported version diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Fields.java similarity index 51% rename from jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java rename to jetty-util/src/main/java/org/eclipse/jetty/util/Fields.java index 25d3047efe0..83b258b8c9f 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Fields.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.spdy.api; +package org.eclipse.jetty.util; import java.util.Arrays; import java.util.Collections; @@ -27,36 +27,36 @@ import java.util.Map; import java.util.Set; /** - *

A container for name/value pairs, known as headers.

- *

A {@link Header} is composed of a case-insensitive name string and + *

A container for name/value pairs, known as fields.

+ *

A {@link Field} is composed of a case-insensitive name string and * of a case-sensitive set of value strings.

*

The implementation of this class is not thread safe.

*/ -public class Headers implements Iterable +public class Fields implements Iterable { - private final Map headers; + private final Map fields; /** - *

Creates an empty modifiable {@link Headers} instance.

- * @see #Headers(Headers, boolean) + *

Creates an empty modifiable {@link Fields} instance.

+ * @see #Fields(Fields, boolean) */ - public Headers() + public Fields() { - headers = new LinkedHashMap<>(); + fields = new LinkedHashMap<>(); } /** - *

Creates a {@link Headers} instance by copying the headers from the given - * {@link Headers} and making it (im)mutable depending on the given {@code immutable} parameter

+ *

Creates a {@link Fields} instance by copying the fields from the given + * {@link Fields} and making it (im)mutable depending on the given {@code immutable} parameter

* - * @param original the {@link Headers} to copy headers from + * @param original the {@link Fields} to copy fields from * @param immutable whether this instance is immutable */ - public Headers(Headers original, boolean immutable) + public Fields(Fields original, boolean immutable) { - Map copy = new LinkedHashMap<>(); - copy.putAll(original.headers); - headers = immutable ? Collections.unmodifiableMap(copy) : copy; + Map copy = new LinkedHashMap<>(); + copy.putAll(original.fields); + fields = immutable ? Collections.unmodifiableMap(copy) : copy; } @Override @@ -66,151 +66,156 @@ public class Headers implements Iterable return true; if (obj == null || getClass() != obj.getClass()) return false; - Headers that = (Headers)obj; - return headers.equals(that.headers); + Fields that = (Fields)obj; + return fields.equals(that.fields); } @Override public int hashCode() { - return headers.hashCode(); + return fields.hashCode(); } /** - * @return a set of header names + * @return a set of field names */ public Set names() { Set result = new LinkedHashSet<>(); - for (Header header : headers.values()) - result.add(header.name); + for (Field field : fields.values()) + result.add(field.name()); return result; } /** - * @param name the header name - * @return the {@link Header} with the given name, or null if no such header exists + * @param name the field name + * @return the {@link Field} with the given name, or null if no such field exists */ - public Header get(String name) + public Field get(String name) { - return headers.get(name.trim().toLowerCase()); + return fields.get(name.trim().toLowerCase()); } /** - *

Inserts or replaces the given name/value pair as a single-valued {@link Header}.

+ *

Inserts or replaces the given name/value pair as a single-valued {@link Field}.

* - * @param name the header name - * @param value the header value + * @param name the field name + * @param value the field value */ public void put(String name, String value) { name = name.trim(); - Header header = new Header(name, value.trim()); - headers.put(name.toLowerCase(), header); + // Preserve the case for the field name + Field field = new Field(name, value); + fields.put(name.toLowerCase(), field); } /** - *

Inserts or replaces the given {@link Header}, mapped to the {@link Header#name() header's name}

+ *

Inserts or replaces the given {@link Field}, mapped to the {@link Field#name() field's name}

* - * @param header the header to add + * @param field the field to put */ - public void put(Header header) + public void put(Field field) { - if (header != null) - headers.put(header.name().toLowerCase(), header); + if (field != null) + fields.put(field.name().toLowerCase(), field); } /** - *

Adds the given value to a header with the given name, creating a {@link Header} is none exists - * for the given name.

+ *

Adds the given value to a field with the given name, + * creating a {@link Field} is none exists for the given name.

* - * @param name the header name - * @param value the header value to add + * @param name the field name + * @param value the field value to add */ public void add(String name, String value) { name = name.trim(); - Header header = headers.get(name.toLowerCase()); - if (header == null) + Field field = fields.get(name.toLowerCase()); + if (field == null) { - header = new Header(name, value.trim()); - headers.put(name.toLowerCase(), header); + field = new Field(name, value); + fields.put(name.toLowerCase(), field); } else { - header = new Header(header.name(), header.value() + "," + value.trim()); - headers.put(name.toLowerCase(), header); + field = new Field(field.name(), field.values(), value); + fields.put(name.toLowerCase(), field); } } /** - *

Removes the {@link Header} with the given name

+ *

Removes the {@link Field} with the given name

* - * @param name the name of the header to remove - * @return the removed header, or null if no such header existed + * @param name the name of the field to remove + * @return the removed field, or null if no such field existed */ - public Header remove(String name) + public Field remove(String name) { name = name.trim(); - return headers.remove(name.toLowerCase()); + return fields.remove(name.toLowerCase()); } /** - *

Empties this {@link Headers} instance from all headers

+ *

Empties this {@link Fields} instance from all fields

* @see #isEmpty() */ public void clear() { - headers.clear(); + fields.clear(); } /** - * @return whether this {@link Headers} instance is empty + * @return whether this {@link Fields} instance is empty */ public boolean isEmpty() { - return headers.isEmpty(); + return fields.isEmpty(); } /** - * @return the number of headers + * @return the number of fields */ public int size() { - return headers.size(); + return fields.size(); } /** - * @return an iterator over the {@link Header} present in this instance + * @return an iterator over the {@link Field}s present in this instance */ @Override - public Iterator
iterator() + public Iterator iterator() { - return headers.values().iterator(); + return fields.values().iterator(); } @Override public String toString() { - return headers.toString(); + return fields.toString(); } /** *

A named list of string values.

*

The name is case-sensitive and there must be at least one value.

*/ - public static class Header + public static class Field { private final String name; private final String[] values; - private Header(String name, String value, String... values) + private Field(String name, String value) + { + this(name, new String[]{value}); + } + + private Field(String name, String[] values, String... moreValues) { this.name = name; - this.values = new String[values.length + 1]; - this.values[0] = value; - if (values.length > 0) - System.arraycopy(values, 0, this.values, 1, values.length); + this.values = new String[values.length + moreValues.length]; + System.arraycopy(values, 0, this.values, 0, values.length); + System.arraycopy(moreValues, 0, this.values, values.length, moreValues.length); } @Override @@ -220,8 +225,8 @@ public class Headers implements Iterable return true; if (obj == null || getClass() != obj.getClass()) return false; - Header that = (Header)obj; - // Header names must be lowercase, thus we lowercase them before transmission, but keep them as is + Field that = (Field)obj; + // Field names must be lowercase, thus we lowercase them before transmission, but keep them as is // internally. That's why we've to compare them case insensitive. return name.equalsIgnoreCase(that.name) && Arrays.equals(values, that.values); } @@ -235,7 +240,7 @@ public class Headers implements Iterable } /** - * @return the header's name + * @return the field's name */ public String name() { @@ -243,7 +248,7 @@ public class Headers implements Iterable } /** - * @return the first header's value + * @return the first field's value */ public String value() { @@ -265,7 +270,7 @@ public class Headers implements Iterable } /** - * @return the header's values + * @return the field's values */ public String[] values() { @@ -273,22 +278,7 @@ public class Headers implements Iterable } /** - * @return the values as a comma separated list - */ - public String valuesAsString() - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; ++i) - { - if (i > 0) - result.append(", "); - result.append(values[i]); - } - return result.toString(); - } - - /** - * @return whether the header has multiple values + * @return whether the field has multiple values */ public boolean hasMultipleValues() {