Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Allow subclassing MultipartSegment #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

defnull
Copy link
Owner

@defnull defnull commented Feb 19, 2025

Allow use of the core parsing functionality for other use cases (e.g. multipart/byterange as described in #73) by allowing users to subclass MultipartSegment.

This is a WIP. First step was to clean up the API between PushMultipartParser and MultipartSegment to make it easier to hook into those APIs. The new MultipartSegment._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, and MultipartSegment 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.

This patch includes refactoring and changes of internal APIs to allow stabilizing those APIs in the future.
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.

1 participant