multipart

package standard library
go1.27.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: BSD-3-Clause Imports: 18 Imported by: 47,069

Documentation

Overview

Package multipart implements MIME multipart parsing, as defined in RFC 2046.

The implementation is sufficient for HTTP (RFC 2388) and the multipart bodies generated by popular browsers.

Limits

To protect against malicious inputs, this package sets limits on the size of the MIME data it processes.

Reader.NextPart and Reader.NextRawPart limit the number of headers in a part to 10000 and Reader.ReadForm limits the total number of headers in all FileHeaders to 10000. These limits may be adjusted with the GODEBUG=multipartmaxheaders=<values> setting.

Reader.ReadForm further limits the number of parts in a form to 1000. This limit may be adjusted with the GODEBUG=multipartmaxparts=<value> setting.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrMessageTooLarge = errors.New("multipart: message too large")

ErrMessageTooLarge is returned by ReadForm if the message form data is too large to be processed.

Functions

func FileContentDisposition added in go1.25.0

func FileContentDisposition(fieldname, filename string) string

FileContentDisposition returns the value of a Content-Disposition header with the provided field name and file name.

Types

type File

type File interface {
	io.Reader
	io.ReaderAt
	io.Seeker
	io.Closer
}

File is an interface to access the file part of a multipart message. Its contents may be either stored in memory or on disk. If stored on disk, the File's underlying concrete type will be an *os.File.

type FileHeader

type FileHeader struct {
	Filename string
	Header   textproto.MIMEHeader