From 1c6813a06d85178c56bae1894a76199b49b3e8a3 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 7 Jul 2010 06:43:34 +0000 Subject: [PATCH] Fixed issue: NETTY-337 Multi-line headers truncated --- .../codec/http/HttpMessageDecoder.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) 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;