HttpMessage.getHeaders() never returns null for convenience

This commit is contained in:
Trustin Lee 2009-06-30 09:39:07 +00:00
parent 6158f7772f
commit 281b4507df
2 changed files with 9 additions and 3 deletions

View File

@ -23,6 +23,7 @@
package org.jboss.netty.handler.codec.http;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -207,7 +208,12 @@ public class DefaultHttpMessage implements HttpMessage {
}
public List<String> getHeaders(final String name) {
return headers.get(name);
List<String> values = headers.get(name);
if (values == null) {
return Collections.emptyList();
} else {
return values;
}
}
public boolean containsHeader(final String name) {

View File

@ -52,8 +52,8 @@ public interface HttpMessage {
/**
* Returns the header values with the specified header name.
*
* @return the {@link List} of header values of {@code null} if there is
* no such header
* @return the {@link List} of header values. An empty list if there is no
* such header.
*/
List<String> getHeaders(String name);