Skip buffered multipart line endings

Merged
KL
2d ago
+101-10

Evaluate the remaining multipart proposal from @deadstrobe5 in issue #365. Consume buffered CRLF sequences directly after header values, at the end of headers, and after between-part boundaries, instead of visiting each intermediate parser state. Split or invalid line endings keep the existing validation paths.

Add a public-API regression test that checks callback order and data across every two-chunk split and byte-by-byte writes, including empty header values and a headerless part. No workflow changes are included.

The earlier local evaluation improved form parsing but showed an approximately 5% slower 8 MB upload case. This PR uses the existing CodSpeed benchmarks to evaluate that tradeoff against current main; no across-the-board speedup is assumed.

Validation on Python 3.13.18:

  • scripts/check, scripts/test --strict-config --strict-markers (188 tests, 100% coverage), and scripts/rename pass.
  • Starlette's full suite at 0f08970e passes with the candidate installed: 1,419 passed, 2 expected failures, 100% line and branch coverage.
  • 30,000 differential multipart cases match callbacks, consumed bytes, and errors across chunking, malformed input, header limits, and body-size limits.

Session: pi --session 01a1e0a2-78a9-7473-86ce-b992bd92cf74