Allocate smaller dynamic buffer to read a line

- Also fixes some inspector warnings from the previous patch
- Related: #992
This commit is contained in:
Trustin Lee 2013-01-29 15:53:43 +09:00
parent 9650cda163
commit b38bde2d2b

View File

@ -1219,17 +1219,17 @@ public class HttpPostRequestDecoder {
private String readLineStandard() throws NotEnoughDataDecoderException {
int readerIndex = undecodedChunk.readerIndex();
try {
ChannelBuffer line = ChannelBuffers.dynamicBuffer();
ChannelBuffer line = ChannelBuffers.dynamicBuffer(64);
while (undecodedChunk.readable()) {
byte nextByte = undecodedChunk.readByte();
if (nextByte == HttpConstants.CR) {
nextByte = undecodedChunk.readByte();
if (nextByte == HttpConstants.LF) {
return line.toString(this.charset);
return line.toString(charset);
}
} else if (nextByte == HttpConstants.LF) {
return line.toString(this.charset);
return line.toString(charset);
} else {
line.writeByte(nextByte);
}
@ -1256,7 +1256,7 @@ public class HttpPostRequestDecoder {
}
int readerIndex = undecodedChunk.readerIndex();
try {
ChannelBuffer line = ChannelBuffers.dynamicBuffer();
ChannelBuffer line = ChannelBuffers.dynamicBuffer(64);
while (sao.pos < sao.limit) {
byte nextByte = sao.bytes[sao.pos ++];
if (nextByte == HttpConstants.CR) {
@ -1264,14 +1264,14 @@ public class HttpPostRequestDecoder {
nextByte = sao.bytes[sao.pos ++];
if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return line.toString(this.charset);
return line.toString(charset);
}
} else {
line.writeByte(nextByte);
}
} else if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return line.toString(this.charset);
return line.toString(charset);
} else {
line.writeByte(nextByte);
}