Skip to content

Conversation

@defnull
Copy link
Owner

@defnull defnull commented Jul 7, 2025

This tries to fix #73 by moving all general purpose parser logic out of MultipartSegment back into the parser where it belongs and isolating form-data specific checks into a private parser method which can be overridden. Developers can now subclass PushMultipartParser and override _create_segment(self, headerlist) to support other multipart stream types (e.g. multipart/byterange or multipart/mixed) if necessary.

The change has a minimal impact on performance and actually performs better for the relevant use cases (large forms or large uploads).

defnull added 2 commits July 7, 2025 13:45
This patch moves segment parsing logic from private MultipartSegment methods back into the PushMultipartParser where it belongs, and isolates the 'form-data' specific checks into a single private method to allow subclasses to support different segment and steam types (e.g. multipart/byterange or multipart/mixed).

change: MultipartSegment.name is now typed as optional, but is still guaranteed to be a string for unmodified versions of the parser.
@defnull defnull changed the title Refactor parser logig to better allow subclassing Refactor parser logic to better allow subclassing Jul 7, 2025
@defnull
Copy link
Owner Author

defnull commented Jul 27, 2025

Merged (manually)

@defnull defnull closed this Jul 27, 2025
@defnull defnull deleted the defnull-refactor-segment branch July 27, 2025 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: support MultipartSegment subclasses in PushMultipartParser

2 participants