Module cow_multipart

Data Types

headers()

headers() = [{iodata(), iodata()}]

Function Index

boundary/0Generate a new random boundary.
close/1Return the closing delimiter of the multipart message.
first_part/2Return the first part's head.
form_data/1Convenience function for extracting information from headers when parsing a multipart/form-data stream.
parse_body/2Parse the body of the current multipart part.
parse_content_disposition/1Parse an RFC 2183 content-disposition value.
parse_content_transfer_encoding/1Parse an RFC 2045 content-transfer-encoding header.
parse_content_type/1Parse an RFC 2045 content-type header.
parse_headers/2Parse the headers for the next multipart part.
part/2Return a part's head.

Function Details

boundary/0

boundary() -> binary()

Generate a new random boundary.

The boundary generated has a low probability of ever appearing in the data.

close/1

close(Boundary::binary()) -> iodata()

Return the closing delimiter of the multipart message.

first_part/2

first_part(Boundary::binary(), Headers::headers()) -> iodata()

Return the first part's head.

This works exactly like the part/2 function except there is no leading \r\n. It's not required to use this function, just makes the output a little smaller and prettier.

form_data/1

form_data(Headers::headers() | #{binary() => binary()}) -> {data, binary()} | {file, binary(), binary(), binary()}

Convenience function for extracting information from headers when parsing a multipart/form-data stream.

parse_body/2

parse_body(Stream::binary(), Boundary::binary()) -> {ok, binary()} | {ok, binary(), binary()} | done | {done, binary()} | {done, binary(), binary()}

Parse the body of the current multipart part.

The body is everything until the next boundary.

parse_content_disposition/1

parse_content_disposition(Bin::binary()) -> {binary(), [{binary(), binary()}]}

Parse an RFC 2183 content-disposition value.

parse_content_transfer_encoding/1

parse_content_transfer_encoding(Bin::binary()) -> binary()

Parse an RFC 2045 content-transfer-encoding header.

parse_content_type/1

parse_content_type(Bin::binary()) -> {binary(), binary(), [{binary(), binary()}]}

Parse an RFC 2045 content-type header.

parse_headers/2

parse_headers(Stream::binary(), Boundary::binary()) -> more | {more, binary()} | {ok, headers(), binary()} | {done, binary()}

Parse the headers for the next multipart part.

This function skips any preamble before the boundary. The preamble may be retrieved using parse_body/2.

This function will accept input of any size, it is up to the caller to limit it if needed.

part/2

part(Boundary::binary(), Headers::headers()) -> iodata()

Return a part's head.


Generated by EDoc