Support multiple boundary buffers in MultipartParser
In a small minority of cases, the multipart boundary can spread across three incoming buffers. Prior to this commit, MultipartParser.BodyState only supported two buffers. If the boundary is spread across three buffers, the first buffer of the three is sent as a whole, even though it contains the first bytes of the boundary. This commit fixes this bug, by enqueuing all prior buffers in a queue, and emitting the ones that cannot contain boundary bytes. Closes gh-27939
This commit is contained in:
@@ -211,10 +211,9 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
private static void verifyContents(Path tempFile, Resource resource) {
|
||||
try {
|
||||
byte[] tempBytes = Files.readAllBytes(tempFile);
|
||||
// Use FileCopyUtils since the resource might reside in a JAR instead of in the file system.
|
||||
byte[] resourceBytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
|
||||
assertThat(tempBytes).isEqualTo(resourceBytes);
|
||||
assertThat(tempFile).hasBinaryContent(resourceBytes);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new AssertionError(ex);
|
||||
|
||||
Reference in New Issue
Block a user