WIP: Allow subclassing MultipartSegment #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow use of the core parsing functionality for other use cases (e.g.
multipart/byterange
as described in #73) by allowing users to subclassMultipartSegment
.This is a WIP. First step was to clean up the API between
PushMultipartParser
andMultipartSegment
to make it easier to hook into those APIs. The newMultipartSegment._on_*
methods are still private APIs and may change between releases, so be careful. But it looks nice now, so future changes should be less likely.One idea was to split the segment class into
MultipartSegmentBase
implementing universal parsing logic only, andMultipartSegment
implementing the additional checks and logic for form-data segments. I tried that, but it reduced throughput by up to 5% in some tests and made documentation more complicated. I'm not sure if I really want that, but it's not from the table just yet.