Skip to content

Conversation

@ptoffy
Copy link
Member

@ptoffy ptoffy commented Jun 17, 2025

Closes #132

This adds a new ContentDisposition type to be able to type-safely parse Content-Disposition header fields.

Also adds some docs

@ptoffy ptoffy requested review from 0xTim and gwynne as code owners June 17, 2025 13:13
Copy link
Contributor

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

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

Apart from the one issue this looks good

@codecov
Copy link

codecov bot commented Oct 27, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@0xTim 0xTim requested a review from Copilot October 27, 2025 11:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new ContentDisposition type for type-safe parsing of Content-Disposition header fields in multipart messages. The implementation aligns with RFC 6266 and RFC 7578 standards, providing structured access to disposition type, name, filename, and additional parameters.

Key changes:

  • Added ContentDisposition struct with support for parsing form-data, attachment, and inline disposition types
  • Replaced direct header parameter manipulation with type-safe parsing
  • Added comprehensive test coverage for parsing and error handling

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Sources/MultipartKit/MultipartPart.swift Added ContentDisposition type and replaced name property with contentDisposition computed property
Sources/MultipartKit/MultipartFormData.swift Updated to use contentDisposition?.name instead of direct part.name access
Sources/MultipartKit/Utilities.swift Added default value parameter to setParameter method
Tests/MultipartKitTests/ContentDispositionTests.swift Added comprehensive test suite for parsing and error handling
Tests/MultipartKitTests/FormDataDecodingTests.swift Updated test data to use standard disposition types (attachment instead of file)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

Various nits.

Comment on lines 29 to 32
/// - Throws: `ContentDisposition.Error` if the header has an invalid format, or is missing required fields.
/// - Returns: A parsed `ContentDisposition` instance.
public var contentDisposition: ContentDisposition? {
get throws(ContentDisposition.Error) {
Copy link
Member

Choose a reason for hiding this comment

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

This claims to throw, but actually returns nil. Either change the behavior or remove both the doc comment and the annotation.

Copy link
Member Author

@ptoffy ptoffy Oct 27, 2025

Choose a reason for hiding this comment

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

It returns nil if there's no such header and throws if it's there but unable to parse it (so we also get diagnostics via the error). It makes sense in my head but happy to change the behaviour to just do one of the two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for returning all the content-disposition parameters

4 participants