Fixed a NPE in HttpMessageDecoder.readHeaders() on a particular malformed header

This commit is contained in:
Trustin Lee 2009-06-15 08:13:52 +00:00
parent f059f91ff4
commit 12acb2cf09

View File

@ -362,19 +362,18 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
if (line.length() != 0) { if (line.length() != 0) {
message.clearHeaders(); message.clearHeaders();
do { do {
switch (line.charAt(0)) { char firstChar = line.charAt(0);
case ' ': case '\t': if (lastHeader != null && (firstChar == ' ' || firstChar == '\t')) {
List<String> current = message.getHeaders(lastHeader); List<String> current = message.getHeaders(lastHeader);
int lastPos = current.size() - 1; int lastPos = current.size() - 1;
String newString = current.get(lastPos) + line.trim(); String newString = current.get(lastPos) + line.trim();
current.set(lastPos, newString); current.set(lastPos, newString);
break; } else {
default:
String[] header = splitHeader(line); String[] header = splitHeader(line);
message.addHeader(header[0], header[1]); message.addHeader(header[0], header[1]);
lastHeader = header[0]; lastHeader = header[0];
}
line = readHeader(buffer); line = readHeader(buffer);
}
} while (line.length() != 0); } while (line.length() != 0);
} }