diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java index e9541d9af7..7382eb8182 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java @@ -428,24 +428,30 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder current = message.getHeaders(lastHeader); - int lastPos = current.size() - 1; - String newString = current.get(lastPos) + line.trim(); - current.set(lastPos, newString); + if (name != null && (firstChar == ' ' || firstChar == '\t')) { + value = value + ' ' + line.trim(); } else { + if (name != null) { + message.addHeader(name, value); + } String[] header = splitHeader(line); - message.addHeader(header[0], header[1]); - lastHeader = header[0]; + name = header[0]; + value = header[1]; } line = readHeader(buffer); } while (line.length() != 0); + + // Add the last header. + if (name != null) { + message.addHeader(name, value); + } } State nextState;