Skip to content

Add a multipart encoder to GutenbergKitHTTP and delete the duplicated multipartBodyStream #545

Description

@jkmassel

Summary

GutenbergKitHTTP has a multipart parser (MultipartPart.parse / parseChunked) but no encoder. The only multipart-building code is MediaUploadServer.multipartBodyStream, which is file-only, hand-rolled, and duplicates RequestBody.makePipedFileSliceStream nearly verbatim — its own doc comment notes it uses "the same pattern as" that helper.

Surfaced during the #357 upload-relay review.

Proposal

Add the encode counterpart to GutenbergKitHTTP: a multipart encoder that takes [MultipartPart] (+ boundary) and streams each part's RequestBody through the same bound-stream primitive makePipedFileSliceStream already uses.

Then:

  • The media-upload re-encode path builds [processed-file part] + [original non-file parts] and calls the encoder, instead of hand-writing the multipart.
  • Delete MediaUploadServer.multipartBodyStream / writeAll.
  • GutenbergKitHTTP gains a symmetric parse ⇄ encode pair.

Context

Split out of #357. The immediate need there — forwarding post / additionalData through the re-encode path — is handled inline via a preamble extension of multipartBodyStream. This issue tracks the cleaner refactor that also removes the duplication.

Files

  • ios/Sources/GutenbergKitHTTP/MultipartPart.swift — parser
  • ios/Sources/GutenbergKitHTTP/RequestBody.swiftmakePipedFileSliceStream
  • ios/Sources/GutenbergKit/Sources/Media/MediaUploadServer.swiftmultipartBodyStream (to delete)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions