View Source hackney_multipart (hackney v1.23.0)
Summary
Functions
decode a multipart form.
encode a list of parts a multipart form. Parts can be under the form:
{file, Path}
: to send a file{file, Path, ExtraHeaders}
: to send a file with extra headers{file, Path, Name, ExtraHeaders}
: to send a file with DOM element name and extra headers{mp_mixed, Name, Boundary}
to send a mixed multipart.{mp_mixed_eof, Boundary}
: to signal the end of the mixed multipart boundary.{Name, Data}
: to send a custom content as a part{Name, Data, ExtraHeaders}
: the same as above but with extra headers.
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.
return the multipart header for a data
return the boundary ending a multipart
return the multipart header for a file that will be sent later
create a generic multipart header
return the mixed multipart header
Return a multipart parser for the given boundary.
create a part
Types
-type body_cont() :: cont(more(body_result())).
-type body_result() :: {body, binary(), body_cont()} | end_of_part().
-type cont(T) :: fun(() -> T).
-type end_of_part() :: {end_of_part, cont(more(part_result()))}.
-type headers() :: {headers, http_headers(), body_cont()}.
-type more(T) :: T | {more, parser(T)}.
-type parser(T) :: fun((binary()) -> T).
-type part_parser() :: parser(more(part_result())).
-type part_result() :: headers() | eof.
-type pattern() :: {binary:cp(), non_neg_integer()}.
Functions
-spec boundary() -> binary().
{file, Path}
: to send a file{file, Path, ExtraHeaders}
: to send a file with extra headers{file, Path, Name, ExtraHeaders}
: to send a file with DOM element name and extra headers{mp_mixed, Name, Boundary}
to send a mixed multipart.{mp_mixed_eof, Boundary}
: to signal the end of the mixed multipart boundary.{Name, Data}
: to send a custom content as a part{Name, Data, ExtraHeaders}
: the same as above but with extra headers.
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:{file, Path}
: to send a file{file, Path, ExtraHeaders}
: to send a file with extra headers{file, Path, Name, ExtraHeaders}
: to send a file with DOM element name and extra headers{mp_mixed, Name, Boundary}
to send a mixed multipart. multipart boundary.{Name, DataLen}
: to send a custom content as a part{Name, DataLen, ExtraHeaders}
: the same as above but with extra headers.
-spec mp_data_header({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()}.
-spec mp_file_header({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()}.
-spec parser(binary()) -> part_parser().