Skip to content

BodyMultipart: Quote boundary parameters - #142

Closed
sameerihs wants to merge 1 commit into
gophertools:mainfrom
sameerihs:multipart-boundary-content-type
Closed

sameerihs wants to merge 1 commit into
gophertools:mainfrom
sameerihs:multipart-boundary-content-type

Conversation

@sameerihs

Copy link
Copy Markdown
Contributor

BodyMultipart concatenates its boundary into Content-Type without quoting
it. Valid custom boundaries such as a:b and a b therefore produce headers
that net/http rejects when parsing multipart form data.

Use mime.FormatMediaType to quote the parameter when needed. A local
httptest regression sends a form through the public Builder API and checks
the field round-trip. The colon and space cases fail before the change and
pass afterward; random and simple-token boundaries are also covered.

Validated with Go 1.27.3 on macOS arm64:

  • Full race/coverage suite across all seven packages.
  • Build, vet, module verification and go mod tidy -diff.
  • Formatting and diff checks.

Tests use local servers or existing replay fixtures. Related to the multipart
config introduced in #119.

@sameerihs
sameerihs marked this pull request as ready for review November 8, 2026 17:43
@earthboundkid

Copy link
Copy Markdown
Collaborator

The change itself looks good. The test should use httptest.NewTestServer and reqtest.Server.

@earthboundkid

Copy link
Copy Markdown
Collaborator

Closed in #144.

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.

2 participants