body_cont() = cont(more(body_result()))
body_result() = {body, binary(), body_cont()} | end_of_part()
cont(T) = fun(() -> T)
end_of_part() = {end_of_part, cont(more(part_result()))}
headers() = {headers, http_headers(), body_cont()}
http_headers() = [{binary(), binary()}]
more(T) = T | {more, parser(T)}
parser(T) = fun((binary()) -> T)
part_parser() = parser(more(part_result()))
part_result() = headers() | eof
boundary/0 | |
decode_form/2 | decode a multipart form. |
encode_form/1 | encode a list of parts a multipart form. |
encode_form/2 | |
len_mp_stream/2 | get the size of a mp stream. |
mp_data_header/2 | return the multipart header for a data. |
mp_eof/1 | return the boundary ending a multipart. |
mp_file_header/2 | return the multipart header for a file that will be sent later. |
mp_header/2 | create a generic multipart header. |
mp_mixed_header/2 | return the mixed multipart header. |
parser/1 | Return a multipart parser for the given boundary. |
part/3 | create a part. |
boundary() -> binary()
decode_form(Boundary::binary(), Body::binary()) -> {ok, list()} | {error, term()}
decode a multipart form.
encode_form(Parts) -> any()
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.encode_form(Parts::list(), Boundary::binary()) -> {binary(), integer()}
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:{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.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(Boundary) -> any()
return the boundary ending a multipart
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(Headers, Boundary) -> any()
create a generic multipart header
mp_mixed_header(X1::{Name::binary(), MixedBoundary::binary()}, Boundary::binary()) -> {binary(), 0}
return the mixed multipart header
parser(Boundary::binary()) -> part_parser()
Return a multipart parser for the given boundary.
part(Content, Headers, Boundary) -> any()
create a part
Generated by EDoc