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

[Multipart] Introduce a bytes -> frames parser #72

Merged
merged 5 commits into from Nov 15, 2023

Conversation

czechboy0
Copy link
Collaborator

Motivation

Start landing the parts of the multipart machinery that is unlikely to change as part of the multipart proposal that's finishing review tomorrow.

Modifications

Introduce a bytes -> frames parser and an async sequence that wraps it.

A "frame" is either the full header fields section or a single chunk of a part body.

Result

We can now frame bytes of a multipart body.

Test Plan

Added unit tests for the state machine, the parser, and the async sequence.

Copy link
Collaborator

@simonjbeaumont simonjbeaumont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really great to me. Only one blocking comment (a typo in the character codes).

Sources/OpenAPIRuntime/Multipart/ByteUtilities.swift Outdated Show resolved Hide resolved
Sources/OpenAPIRuntime/Multipart/MultipartParser.swift Outdated Show resolved Hide resolved
czechboy0 and others added 4 commits November 14, 2023 16:46
@czechboy0 czechboy0 merged commit cefdc80 into apple:main Nov 15, 2023
8 checks passed
@czechboy0 czechboy0 deleted the hd-multipart-parser branch November 15, 2023 08:48
czechboy0 added a commit that referenced this pull request Nov 16, 2023
### Motivation

Second state machine, doing the inverse of #72, serializes frames into
bytes.

### Modifications

- A new state machine.
- A new serializer wrapping the state machine.
- An async sequence wrapping the serializer.

### Result

We can now serialize multipart frames into bytes.

### Test Plan

Unit tests for all 3 layers.
@czechboy0 czechboy0 added the semver/patch No public API change. label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants