Repository navigation
test: cover multipart files sharing a field name - #1483
Conversation
Motivation: RFC 7578 allows multiple files for one form field. The FormData model documentation incorrectly describes field names as unique. Modification: Assert exact ordered output for three distinct files sharing one field in both strict and streamed form data, and correct the model Scaladoc. Result: The existing flat multipart representation is documented and protected against ordering or encoding regressions. Production logic is unchanged. Tests: - New MarshallingSpec case: 1 passed. - Full MarshallingSpec: 21 passed on Scala 2.13.18 / Temurin 21.0.13. - Scoped header checks, Scalafmt 3.11.5, and git diff --check passed. References: None - RFC 7578 section 4.3 and Netty #9270 motivated the coverage. https://www.rfc-editor.org/rfc/rfc7578.html#section-4.3 netty/netty#9270
pjfanning
left a comment
There was a problem hiding this comment.
Thanks. The scaladoc correction is right: RFC 7578 §4.3 explicitly allows several parts with the same name, so "All parts must have distinct names" was wrong. The marshalling test pins the order and bytes for both strict and streamed rendering.
Suggestion: the receiving direction is probably more useful to pin. Unmarshalling that same body to Multipart.FormData (and through toStrict) and checking that the three files parts come back in order with their filenames would show that duplicates aren't collapsed anywhere on the parsing side. The Map-based FormData factories obviously can't express duplicates, but nothing currently tests that the parser keeps them.
Motivation: The existing regression checks outgoing form data but does not cover whether parsing preserves multiple files with the same field name. Modification: Unmarshal three same-name files from strict and one-byte-streamed input. After toStrict, check their wire order, filenames, content types and bytes in the CRLF and LF suites. Result: Covers the receiving direction without changing production behavior. Tests: Independent source review and git diff --check passed. The focused pre-submission test run had not completed when this commit was prepared. References: Refs apache#1483 and RFC 7578 section 4.3.
pjfanning
left a comment
There was a problem hiding this comment.
Thanks for adding the receiving direction. The new test parses three same-name files parts from both strict and one-byte-chunked input, in the CRLF and LF suites. haveParts compares a Seq, so order, filenames, content types and bytes are all checked.
Minor: the .flatMap(_.toStrict(1.second.dilated)) before haveParts isn't needed, since haveParts already strictifies each part. Harmless, though.
Motivation: Several recently merged PRs left review points unaddressed: docs that were asked to be dropped, comments and tests that were suggested, and small API and internal tidy-ups. Modification: - Add a Scala FilenameEncoding alias and values to Multipart.FormData and use them in the Scala toEntity signature and tests (#1494). - Render the form-data Content-Disposition header directly instead of rendering it twice and slicing off the prefix (#1494). - Drop the docs paragraph about unpaired URI surrogates (#1426) and the cookie -0000 sentence in request-level.md (#1493). - Fix the javadsl Multipart.FormData doc the same way #1483 fixed the scaladsl one. - Comment the cookie date rule copies so they stay in sync (#1458). - Test custom methods starting with Q next to the QUERY fast path (#1477). - Use one root package import and a dilated timeout in HeaderCompressionSpec (#1438). - Pass isTrailer to HttpMessageRendering.renderHeaders explicitly (#1463). - Remove the unused forwarding overloads in Handshake.Client and EnabledPingState (#1436, #1462). - Move the media type model checks from the routing spec to a new http-core MediaTypesSpec (#1437, #1454). - Hash the WebSocket key without String.valueOf (#1439). Result: The review points are addressed. The only public API change is the added Scala FilenameEncoding alias. Tests: - http-core/testOnly MultipartSpec MultipartsSpec MediaTypesSpec RequestParserCRLFSpec RequestParserLFSpec HeaderCompressionSpec WebSocketClientSpec HeaderSpec HttpHeaderSpec: 314 passed - http2-tests/testOnly HttpMessageRenderingSpec Http2PingSchedulingSpec: 38 passed - http-tests/testOnly FileAndResourceDirectivesSpec: 63 passed - http-core/mimaReportBinaryIssues: passed References: Refs #1426, #1436, #1437, #1438, #1439, #1454, #1458, #1462, #1463, #1477, #1483, #1493, #1494
Motivation: Existing multipart cases cover ordered same-name files and optional filename decoding but not literal consecutive ASCII spaces in filenames. Modification: Round-trip one short modeled multipart part through strict and streamed form data. Assert the quoted filename in strict output and compare the complete decoded part, including the name, content, and filename. Result: Both entity forms protect the existing behavior of preserving both spaces. No production code, API, or network behavior changes. Tests: - JDK 17, Scala 2.13.18 and 3.3.9: 8/8 each across the two MultipartUnmarshallersSpec suite classes, including the new round-trip in each and the adjacent same-name and percent-decoding controls. Exact test source was compiled against source-matching cached runtime classes. The new fixture uses the normal renderer's CRLF in both suites. - Scoped Scalafmt 3.11.5 and git diff --check passed. - Full sbt CI was not run. References: Refs #1483 and #1497; RFC 7578 Section 4.2.
Motivation:
RFC 7578 allows multiple files for one form field. The FormData model documentation incorrectly describes field names as unique.
Modification:
Assert exact ordered output for three distinct files sharing one field in both strict and streamed form data, and correct the model Scaladoc.
Result:
The existing flat multipart representation is documented and protected against ordering or encoding regressions. Production logic is unchanged.
Tests:
References:
None - RFC 7578 section 4.3 and Netty #9270 motivated the coverage. https://www.rfc-editor.org/rfc/rfc7578.html#section-4.3 netty/netty#9270