Module hackney_multipart

module to encode/decode multipart.

Description

module to encode/decode multipart

Data Types

body_cont()

body_cont() = cont(more(body_result()))

body_result()

body_result() = {body, binary(), body_cont()} | end_of_part()

cont()

cont(T) = fun(() -> T)

end_of_part()

end_of_part() = {end_of_part, cont(more(part_result()))}

headers()

headers() = {headers, http_headers(), body_cont()}

http_headers()

http_headers() = [{binary(), binary()}]

more()

more(T) = T | {more, parser(T)}

parser()

parser(T) = fun((binary()) -> T)

part_parser()

part_parser() = parser(more(part_result()))

part_result()

part_result() = headers() | eof

Function Index

boundary/0
decode_form/2decode a multipart form.
encode_form/1encode a list of parts a multipart form.
encode_form/2
len_mp_stream/2get the size of a mp stream.
mp_data_header/2return the multipart header for a data.
mp_eof/1return the boundary ending a multipart.
mp_file_header/2return the multipart header for a file that will be sent later.
mp_header/2create a generic multipart header.
mp_mixed_header/2return the mixed multipart header.
parser/1Return a multipart parser for the given boundary.
part/3create a part.

Function Details

boundary/0

boundary() -> binary()

decode_form/2

decode_form(Boundary::binary(), Body::binary()) -> {ok, list()} | {error, term()}

decode a multipart form.

encode_form/1

encode_form(Parts) -> any()

encode a list of parts a multipart form. Parts can be under the form:

encode_form/2

encode_form(Parts::list(), Boundary::binary()) -> {binary(), integer()}

len_mp_stream/2

len_mp_stream(Parts, Boundary) -> any()

get the size of a mp stream. Useful to calculate the content-length of a full multipart stream and send it as an identity transfer-encoding instead of chunked so any server can handle it.

Calculated Parts can be under the form:

mp_data_header/2

mp_data_header(X1::{Name::binary(), DataLen::integer()} | {Name::binary(), DataLen::integer(), ExtraHeaders::[{binary(), binary()}]} | {Name::binary(), DataLen::integer(), {Disposition::binary(), Params::[{binary(), binary()}]}, ExtraHeaders::[{binary(), binary()}]}, Boundary::binary()) -> {binary(), DataLen::integer()}

return the multipart header for a data

mp_eof/1

mp_eof(Boundary) -> any()

return the boundary ending a multipart

mp_file_header/2

mp_file_header(X1::{file, Path::binary()} | {file, Path::binary(), ExtraHeaders::[{binary(), binary()}]} | {file, Path::binary(), Name::binary(), ExtraHeaders::[{binary(), binary()}]} | {file, Path::binary(), {Disposition::binary(), Params::[{binary(), binary()}]}, ExtraHeaders::[{binary(), binary()}]}, Boundary::binary()) -> {binary(), FileSize::integer()}

return the multipart header for a file that will be sent later

mp_header/2

mp_header(Headers, Boundary) -> any()

create a generic multipart header

mp_mixed_header/2

mp_mixed_header(X1::{Name::binary(), MixedBoundary::binary()}, Boundary::binary()) -> {binary(), 0}

return the mixed multipart header

parser/1

parser(Boundary::binary()) -> part_parser()

Return a multipart parser for the given boundary.

part/3

part(Content, Headers, Boundary) -> any()

create a part


Generated by EDoc