No need to slice before copy. Part of #1848
This commit is contained in:
parent
951dcc6c10
commit
812b0d11c2
@ -538,7 +538,7 @@ public class HttpPostRequestDecoder {
|
||||
if (read == '&') {
|
||||
currentStatus = MultiPartStatus.DISPOSITION;
|
||||
ampersandpos = currentpos - 1;
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = true;
|
||||
} else if (read == HttpConstants.CR) {
|
||||
@ -548,7 +548,7 @@ public class HttpPostRequestDecoder {
|
||||
if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 2;
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = false;
|
||||
} else {
|
||||
@ -561,7 +561,7 @@ public class HttpPostRequestDecoder {
|
||||
} else if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 1;
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = false;
|
||||
}
|
||||
@ -575,7 +575,7 @@ public class HttpPostRequestDecoder {
|
||||
// special case
|
||||
ampersandpos = currentpos;
|
||||
if (ampersandpos > firstpos) {
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
} else if (!currentAttribute.isCompleted()) {
|
||||
setFinalBuffer(EMPTY_BUFFER);
|
||||
}
|
||||
@ -586,7 +586,7 @@ public class HttpPostRequestDecoder {
|
||||
if (contRead && currentAttribute != null) {
|
||||
// reset index except if to continue in case of FIELD getStatus
|
||||
if (currentStatus == MultiPartStatus.FIELD) {
|
||||
currentAttribute.addContent(undecodedChunk.slice(firstpos, currentpos - firstpos).copy(),
|
||||
currentAttribute.addContent(undecodedChunk.copy(firstpos, currentpos - firstpos),
|
||||
false);
|
||||
firstpos = currentpos;
|
||||
}
|
||||
@ -659,7 +659,7 @@ public class HttpPostRequestDecoder {
|
||||
if (read == '&') {
|
||||
currentStatus = MultiPartStatus.DISPOSITION;
|
||||
ampersandpos = currentpos - 1;
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = true;
|
||||
} else if (read == HttpConstants.CR) {
|
||||
@ -670,7 +670,7 @@ public class HttpPostRequestDecoder {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 2;
|
||||
sao.setReadPosition(0);
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = false;
|
||||
break loop;
|
||||
@ -688,7 +688,7 @@ public class HttpPostRequestDecoder {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 1;
|
||||
sao.setReadPosition(0);
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = false;
|
||||
break loop;
|
||||
@ -705,7 +705,7 @@ public class HttpPostRequestDecoder {
|
||||
// special case
|
||||
ampersandpos = currentpos;
|
||||
if (ampersandpos > firstpos) {
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos).copy());
|
||||
setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
|
||||
} else if (!currentAttribute.isCompleted()) {
|
||||
setFinalBuffer(EMPTY_BUFFER);
|
||||
}
|
||||
@ -716,7 +716,7 @@ public class HttpPostRequestDecoder {
|
||||
if (contRead && currentAttribute != null) {
|
||||
// reset index except if to continue in case of FIELD getStatus
|
||||
if (currentStatus == MultiPartStatus.FIELD) {
|
||||
currentAttribute.addContent(undecodedChunk.slice(firstpos, currentpos - firstpos).copy(),
|
||||
currentAttribute.addContent(undecodedChunk.copy(firstpos, currentpos - firstpos),
|
||||
false);
|
||||
firstpos = currentpos;
|
||||
}
|
||||
@ -1648,7 +1648,7 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
}
|
||||
}
|
||||
ByteBuf buffer = undecodedChunk.slice(readerIndex, lastPosition - readerIndex).copy();
|
||||
ByteBuf buffer = undecodedChunk.copy(readerIndex, lastPosition - readerIndex);
|
||||
if (found) {
|
||||
// found so lastPosition is correct and final
|
||||
try {
|
||||
@ -1766,7 +1766,7 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
}
|
||||
lastPosition = sao.getReadPosition(lastrealpos);
|
||||
ByteBuf buffer = undecodedChunk.slice(readerIndex, lastPosition - readerIndex).copy();
|
||||
ByteBuf buffer = undecodedChunk.copy(readerIndex, lastPosition - readerIndex);
|
||||
if (found) {
|
||||
// found so lastPosition is correct and final
|
||||
try {
|
||||
@ -1865,7 +1865,7 @@ public class HttpPostRequestDecoder {
|
||||
// so go back of delimiter size
|
||||
try {
|
||||
currentAttribute.addContent(
|
||||
undecodedChunk.slice(readerIndex, lastPosition - readerIndex).copy(), true);
|
||||
undecodedChunk.copy(readerIndex, lastPosition - readerIndex), true);
|
||||
} catch (IOException e) {
|
||||
throw new ErrorDataDecoderException(e);
|
||||
}
|
||||
@ -1873,7 +1873,7 @@ public class HttpPostRequestDecoder {
|
||||
} else {
|
||||
try {
|
||||
currentAttribute.addContent(
|
||||
undecodedChunk.slice(readerIndex, lastPosition - readerIndex).copy(), false);
|
||||
undecodedChunk.copy(readerIndex, lastPosition - readerIndex), false);
|
||||
} catch (IOException e) {
|
||||
throw new ErrorDataDecoderException(e);
|
||||
}
|
||||
@ -1970,7 +1970,7 @@ public class HttpPostRequestDecoder {
|
||||
// so go back of delimiter size
|
||||
try {
|
||||
currentAttribute.addContent(
|
||||
undecodedChunk.slice(readerIndex, lastPosition - readerIndex).copy(), true);
|
||||
undecodedChunk.copy(readerIndex, lastPosition - readerIndex), true);
|
||||
} catch (IOException e) {
|
||||
throw new ErrorDataDecoderException(e);
|
||||
}
|
||||
@ -1978,7 +1978,7 @@ public class HttpPostRequestDecoder {
|
||||
} else {
|
||||
try {
|
||||
currentAttribute.addContent(
|
||||
undecodedChunk.slice(readerIndex, lastPosition - readerIndex).copy(), false);
|
||||
undecodedChunk.copy(readerIndex, lastPosition - readerIndex), false);
|
||||
} catch (IOException e) {
|
||||
throw new ErrorDataDecoderException(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user