bring back entries()

This commit is contained in:
Bill Gallagher 2013-10-11 15:49:33 -04:00 committed by Trustin Lee
parent e6eb7fa466
commit c1704039f0
2 changed files with 31 additions and 1 deletions

View File

@ -239,6 +239,19 @@ public class DefaultSpdyHeaders extends SpdyHeaders {
return values;
}
@Override
public List<Map.Entry<String, String>> entries() {
List<Map.Entry<String, String>> all =
new LinkedList<Map.Entry<String, String>>();
HeaderEntry e = head.after;
while (e != head) {
all.add(e);
e = e.after;
}
return all;
}
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return new HeaderIterator();

View File

@ -38,6 +38,11 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
return Collections.emptyList();
}
@Override
public List<Map.Entry<String, String>> entries() {
return Collections.emptyList();
}
@Override
public boolean contains(String name) {
return false;
@ -85,7 +90,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return Collections.<Map.Entry<String, String>>emptyList().iterator();
return entries().iterator();
}
@Override
@ -415,6 +420,10 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
frame.headers().set(HttpNames.VERSION, httpVersion.text());
}
}
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return entries().iterator();
}
/**
* Returns the header value with the specified header name. If there is
@ -433,6 +442,14 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
*/
public abstract List<String> getAll(String name);
/**
* Returns all header names and values that this frame contains.
*
* @return the {@link List} of the header name-value pairs. An empty list
* if there is no header in this message.
*/
public abstract List<Map.Entry<String, String>> entries();
/**
* Returns {@code true} if and only if there is a header with the specified
* header name.