Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · multipart

Docs

std/multipart

On this page

Index

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).

Source: std/multipart.xo:11

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.

Source: std/multipart.xo:19

MultipartErr

struct MultipartErr {
  msg: Str
}

Go’s error texts: multipart: NextPart: EOF, multipart: message too large, unexpected EOF, malformed MIME header line: ....

Source: std/multipart.xo:26

MultipartErr.display

fn (e: MultipartErr) display() -> Str

Source: std/multipart.xo:30

Functions

parse

fn parse(body: Bytes, boundary: Str) -> List[Part] ! MultipartErr

Every part (Reader.NextPart, each part read whole; a quoted-printable part decoded).

Source: std/multipart.xo:34

parse_form

fn parse_form(body: Bytes, boundary: Str, max_parts: Int = 1000) -> Form ! MultipartErr

Reader.ReadForm with Go’s limits (the 32 MB of http’s ParseMultipartForm, max_parts, 10,000 headers).

Source: std/multipart.xo:37

write

fn write(parts: List[Part], boundary: Str) -> Bytes

A body of the parts (Writer): each part’s headers sorted, a Content-Disposition from name and filename when the part has none.

Source: std/multipart.xo:40

form_data_content_type

fn form_data_content_type(boundary: Str) -> Str

multipart/form-data; boundary=... (Writer.FormDataContentType).

Source: std/multipart.xo:42

random_boundary

fn random_boundary(r: Rand) -> Str uses rand

60 hex digits from 30 random bytes (Writer’s boundary).

Source: std/multipart.xo:44

↑ index