wordpress-mobile / wordpress-mobile/GutenbergKit

Add a multipart encoder to GutenbergKitHTTP and delete the duplicated multipartBodyStream

Open
#545 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29
Forks
6
Avg merge
1d 9h
Merged PRs (30d)
41

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ios/Sources/GutenbergKitHTTP/MultipartPart.swift and RequestBody.swift, comparing the parser with makePipedFileSliceStream. Then inspect MediaUploadServer.swift to trace multipartBodyStream and writeAll. Done means the encoder streams all MultipartPart values, the media re-encode path uses it, and the duplicated helpers are deleted without losing non-file parts.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.