Skip to content

Commit 826114d

Browse files
committed
Increase part number after we process each chunk, even the last chunk (to be consistent)
1 parent 7c5689a commit 826114d

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

Source/HttpMultipartParser/StreamingMultipartFormDataParser.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ private void ParseFilePart(Dictionary<string, string> parameters, RebufferableBi
655655
// We also want to chop off the newline that is inserted by the protocl.
656656
// We can do this by reducing endPos by the length of newline in this environment
657657
// and encoding
658-
FileHandler(name, filename, contentType, contentDisposition, fullBuffer, endPos - bufferNewlineLength, partNumber);
658+
FileHandler(name, filename, contentType, contentDisposition, fullBuffer, endPos - bufferNewlineLength, partNumber++);
659659

660660
int writeBackOffset = endPos + endPosLength + boundaryNewlineOffset;
661661
int writeBackAmount = (prevLength + curLength) - writeBackOffset;
@@ -665,8 +665,7 @@ private void ParseFilePart(Dictionary<string, string> parameters, RebufferableBi
665665
}
666666

667667
// No end, consume the entire previous buffer
668-
FileHandler(name, filename, contentType, contentDisposition, prevBuffer, prevLength, partNumber);
669-
partNumber++; // increase part counter
668+
FileHandler(name, filename, contentType, contentDisposition, prevBuffer, prevLength, partNumber++);
670669

671670
// Now we want to swap the two buffers, we don't care
672671
// what happens to the data from prevBuffer so we set
@@ -807,7 +806,7 @@ private async Task ParseFilePartAsync(Dictionary<string, string> parameters, Reb
807806
// We also want to chop off the newline that is inserted by the protocl.
808807
// We can do this by reducing endPos by the length of newline in this environment
809808
// and encoding
810-
FileHandler(name, filename, contentType, contentDisposition, fullBuffer, endPos - bufferNewlineLength, partNumber);
809+
FileHandler(name, filename, contentType, contentDisposition, fullBuffer, endPos - bufferNewlineLength, partNumber++);
811810

812811
int writeBackOffset = endPos + endPosLength + boundaryNewlineOffset;
813812
int writeBackAmount = (prevLength + curLength) - writeBackOffset;
@@ -817,8 +816,7 @@ private async Task ParseFilePartAsync(Dictionary<string, string> parameters, Reb
817816
}
818817

819818
// No end, consume the entire previous buffer
820-
FileHandler(name, filename, contentType, contentDisposition, prevBuffer, prevLength, partNumber);
821-
partNumber++; // increase part counter
819+
FileHandler(name, filename, contentType, contentDisposition, prevBuffer, prevLength, partNumber++);
822820

823821
// Now we want to swap the two buffers, we don't care
824822
// what happens to the data from prevBuffer so we set

0 commit comments

Comments
 (0)