Fixed issue: NETTY-337 Multi-line headers truncated
This commit is contained in:
parent
3156ed5dd5
commit
1c6813a06d
@ -428,24 +428,30 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
|||||||
headerSize = 0;
|
headerSize = 0;
|
||||||
final HttpMessage message = this.message;
|
final HttpMessage message = this.message;
|
||||||
String line = readHeader(buffer);
|
String line = readHeader(buffer);
|
||||||
String lastHeader = null;
|
String name = null;
|
||||||
|
String value = null;
|
||||||
if (line.length() != 0) {
|
if (line.length() != 0) {
|
||||||
message.clearHeaders();
|
message.clearHeaders();
|
||||||
do {
|
do {
|
||||||
char firstChar = line.charAt(0);
|
char firstChar = line.charAt(0);
|
||||||
if (lastHeader != null && (firstChar == ' ' || firstChar == '\t')) {
|
if (name != null && (firstChar == ' ' || firstChar == '\t')) {
|
||||||
List<String> current = message.getHeaders(lastHeader);
|
value = value + ' ' + line.trim();
|
||||||
int lastPos = current.size() - 1;
|
|
||||||
String newString = current.get(lastPos) + line.trim();
|
|
||||||
current.set(lastPos, newString);
|
|
||||||
} else {
|
} else {
|
||||||
|
if (name != null) {
|
||||||
|
message.addHeader(name, value);
|
||||||
|
}
|
||||||
String[] header = splitHeader(line);
|
String[] header = splitHeader(line);
|
||||||
message.addHeader(header[0], header[1]);
|
name = header[0];
|
||||||
lastHeader = header[0];
|
value = header[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
line = readHeader(buffer);
|
line = readHeader(buffer);
|
||||||
} while (line.length() != 0);
|
} while (line.length() != 0);
|
||||||
|
|
||||||
|
// Add the last header.
|
||||||
|
if (name != null) {
|
||||||
|
message.addHeader(name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
State nextState;
|
State nextState;
|
||||||
|
Loading…
Reference in New Issue
Block a user