Skip to content

Feature request: support MultipartSegment subclasses in PushMultipartParser #73

@himikof

Description

@himikof

I'm interested in parsing multipart/byteranges response data using this library. I think that it is a good match because this format does not require any logic changes in PushMultipartParser, and it is not a deprecated format in any way (just not used very often).

I understand if direct support would be considered out of scope for this library, given its focus on multipart/form-data, but is quite a shame to be unable to reuse the high-quality core parsing implementation.

The simplest way to allow this usage I can think of would be to support passing a MultipartSegment subclass to PushMultipartParser constructor, and then yielding instances of this class instead of hard-coded MultipartSegment in PushMultipartParser.parse.
As a further (optional) improvement, MultipartSegment could be refactored into BaseMultipartSegment and MultipartSegment, where BaseMultipartSegment would have only the header list manipulation implemented, and multipart/form-data-specific concrete implementations of state transition callbacks would be in the MultipartSegment proper.

An external implementation of multipart/byteranges would then create a custom subclass of MultipartSegment (or BaseMultipartSegment), implement the state transition callbacks differently (parsing Content-Range instead of Content-Disposition, for example) and provide a different interface to access the parsed metadata.

What do you think of this suggestion? I could prepare a PR if the overall direction is acceptable.

Metadata

Metadata

Assignees

Labels

AcceptedFeatureFeature requests or other non-bugs

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions