]> Cypherpunks repositories - gostls13.git/commit
mime/multipart: add helper to build content-disposition header contents
authorLuca Maltagliati <lmalta95@gmail.com>
Wed, 12 Mar 2025 21:40:12 +0000 (21:40 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 12 Mar 2025 23:20:01 +0000 (16:20 -0700)
commitd729053edffdfb17ee947cee8af0d7edc45f6111
treeb5b2d20ca584c20e4207323517b6676126359f10
parenta68bf75d3402412a1946fe1df67f57ca923f1507
mime/multipart: add helper to build content-disposition header contents

This PR adds an helper FileContentDisposition that builds multipart
Content-Disposition header contents with field name and file name,
escaping quotes and escape characters.

The  function is then called in the related helper CreateFormFile.

The new function allows users to add other custom MIMEHeaders,
without having to rewrite the char escaping logic of field name and
file name, which is provided by the new helper.

Fixes #46771

Change-Id: Ifc82a79583feb6dd609ca1e6024e612fb58c05ce
GitHub-Last-Rev: 969f846fa967d2b3eca7a21ee096b299b8a94546
GitHub-Pull-Request: golang/go#63324
Reviewed-on: https://go-review.googlesource.com/c/go/+/531995
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
api/next/46771.txt [new file with mode: 0644]
doc/next/6-stdlib/99-minor/mime/multipart/46771.md [new file with mode: 0644]
src/mime/multipart/writer.go
src/mime/multipart/writer_test.go