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.swift — makePipedFileSliceStream
ios/Sources/GutenbergKit/Sources/Media/MediaUploadServer.swift — multipartBodyStream (to delete)
Summary
GutenbergKitHTTPhas a multipart parser (MultipartPart.parse/parseChunked) but no encoder. The only multipart-building code isMediaUploadServer.multipartBodyStream, which is file-only, hand-rolled, and duplicatesRequestBody.makePipedFileSliceStreamnearly 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'sRequestBodythrough the same bound-stream primitivemakePipedFileSliceStreamalready uses.Then:
[processed-file part] + [original non-file parts]and calls the encoder, instead of hand-writing the multipart.MediaUploadServer.multipartBodyStream/writeAll.GutenbergKitHTTPgains 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 ofmultipartBodyStream. This issue tracks the cleaner refactor that also removes the duplication.Files
ios/Sources/GutenbergKitHTTP/MultipartPart.swift— parserios/Sources/GutenbergKitHTTP/RequestBody.swift—makePipedFileSliceStreamios/Sources/GutenbergKit/Sources/Media/MediaUploadServer.swift—multipartBodyStream(to delete)