From cd5f5732a246ecd13ad1280fbf3b5fe4b7122217 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 4 Dec 2008 02:17:22 +0000 Subject: [PATCH] Added HttpMessage.setHeader(String, String) --- .../netty/handler/codec/http/DefaultHttpMessage.java | 10 ++++++++++ .../jboss/netty/handler/codec/http/HttpMessage.java | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java index 71af8bde4a..6df31f2749 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java @@ -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 values = new ArrayList(1); + values.add(value); + headers.put(name, values); + } + public void setHeader(final String name, final List values) { if (values == null || values.size() == 0) { throw new NullPointerException("no values present"); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java index 82a2381030..6b45dc9899 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java @@ -49,6 +49,8 @@ public interface HttpMessage { void addHeader(String name, String value); + void setHeader(String name, String value); + void setHeader(String name, List values); void removeHeader(String name);