Added HttpMessage.setHeader(String, String)

This commit is contained in:
Trustin Lee 2008-12-04 02:17:22 +00:00
parent f183b3d965
commit cd5f5732a2
2 changed files with 12 additions and 0 deletions

View File

@ -60,6 +60,16 @@ public class DefaultHttpMessage implements HttpMessage {
headers.get(name).add(value);
}
public void setHeader(final String name, final String value) {
if (value == null) {
throw new NullPointerException("value");
}
List<String> values = new ArrayList<String>(1);
values.add(value);
headers.put(name, values);
}
public void setHeader(final String name, final List<String> values) {
if (values == null || values.size() == 0) {
throw new NullPointerException("no values present");

View File

@ -49,6 +49,8 @@ public interface HttpMessage {
void addHeader(String name, String value);
void setHeader(String name, String value);
void setHeader(String name, List<String> values);
void removeHeader(String name);