std/multipart
On this page
Index
- type
Part - type
Form - type
MultipartErr- method
MultipartErr.display
- method
- fn
parse - fn
parse_form - fn
write - fn
form_data_content_type - fn
random_boundary
Types
Part
struct Part {
name: Str
filename: Str?
headers: Map[Str, Str]
data: Bytes
}One part. name is the form field (Content-Disposition form-data’s
name, else “”); filename its file name, the last path element as
Go’s FileName; headers the first value of each header, keys in
canonical form (Content-Type).
Form
struct Form {
values: url.Values
files: Map[Str, List[Part]]
}A form: the fields without a file name, and the file parts by field.
MultipartErr
struct MultipartErr {
msg: Str
}Go’s error texts: multipart: NextPart: EOF, multipart: message too large, unexpected EOF, malformed MIME header line: ....
MultipartErr.display
fn (e: MultipartErr) display() -> StrFunctions
parse
fn parse(body: Bytes, boundary: Str) -> List[Part] ! MultipartErrEvery part (Reader.NextPart, each part read whole; a quoted-printable part decoded).
parse_form
fn parse_form(body: Bytes, boundary: Str, max_parts: Int = 1000) -> Form ! MultipartErrReader.ReadForm with Go’s limits (the 32 MB of http’s
ParseMultipartForm, max_parts, 10,000 headers).
write
fn write(parts: List[Part], boundary: Str) -> BytesA body of the parts (Writer): each part’s headers sorted, a
Content-Disposition from name and filename when the part has none.
form_data_content_type
fn form_data_content_type(boundary: Str) -> Strmultipart/form-data; boundary=... (Writer.FormDataContentType).
random_boundary
fn random_boundary(r: Rand) -> Str uses rand60 hex digits from 30 random bytes (Writer’s boundary).
↑ index