From f8966d241a618e9a0f6ac7e3b427e0e4ad1be69b Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Sat, 19 Dec 2020 02:24:37 +0000 Subject: [PATCH] Fix doc. --- src/hackney.erl | 26 +++++++------- src/hackney_http.erl | 71 ++++++++++++++++++++------------------- src/hackney_multipart.erl | 40 ++++++++++++---------- 3 files changed, 73 insertions(+), 64 deletions(-) diff --git a/src/hackney.erl b/src/hackney.erl index 8a3da7c6..20d89a38 100644 --- a/src/hackney.erl +++ b/src/hackney.erl @@ -94,17 +94,19 @@ cancel_request(Ref) -> %% @doc set client options. %% Options are: -%% - `async': to fetch the response asynchronously -%% - `{async, once}': to receive the response asynchronously one time. -%% To receive the next message use the function `hackney:stream_next/1'. -%% - `{stream_to, pid()}': to set the pid where the messages of an -%% asynchronous response will be sent. -%% - `{follow_redirect, bool()}' : if true a redirection will be -%% followed when the response is received synchronously -%% - `{force_redirect, bool()}' : if true a 301/302 redirection will be -%% followed even on POST. -%% - `{max_redirect, integer()}' the maximum number of redirections that -%% will be followed +%% -spec setopts(client_ref(), list()) -> ok. setopts(Ref, Options) -> hackney_manager:get_state(Ref, fun(State) -> @@ -419,7 +421,7 @@ finish_send_body(Ref) -> %%
  • `{part, Name}': to start sending a part without length in a streaming %% fashion
  • %%
  • `{part, Name, ExtraHeader}': to start sending a part without -%% lengthin a streaming fashion
  • +%% length in a streaming fashion %%
  • `{part_bin, Bin}': To send part of part
  • %%
  • `{part, eof}': To notify the end of the part
  • %%
  • `{mp_mixed, Name, MixedBoundary}': To notify we start a part with a a mixed diff --git a/src/hackney_http.erl b/src/hackney_http.erl index 3a9f2331..c1018ccf 100644 --- a/src/hackney_http.erl +++ b/src/hackney_http.erl @@ -23,32 +23,33 @@ %%% you can process later with `hackney_http:execute/2' when %%% `{more, ...}' is returnned or `hackney_http:execute/1' in other %%% cases: -%%% -%%% - `{response, http_version(), status(), http_reason(), parser()}': -%%% when the first line of a response is parsed -%%% - `{request, http_version(), http_method(), uri(), parser()}': -%%% when the first line of a request (on servers) is parsed -%%% - `{more, parser()}': when the parser need more +%%% -module(hackney_http). @@ -102,14 +103,14 @@ parser() -> %% %% Available options: %% -spec parser(parser_options()) -> parser(). parser(Options) -> @@ -117,14 +118,16 @@ parser(Options) -> %% @doc retrieve a parser property. %% Properties are: -%% - `buffer': internal buffer of the parser (non parsed) -%% - `state': the current state (on_status, on_header, on_body, done) -%% - `version': HTTP version -%% - `content_length': content length header if any -%% - `transfer_encoding': transfer encoding header if any -%% - `content_type': content type header if any -%% - `location': location header if any -%% - `connection': connection header if any. +%% -spec get(parser(), atom() | [atom()]) -> any(). get(Parser, Props) when is_list(Props) -> [get_property(P, Parser) || P <- Props]; diff --git a/src/hackney_multipart.erl b/src/hackney_multipart.erl index 38cb9eb4..3e570878 100644 --- a/src/hackney_multipart.erl +++ b/src/hackney_multipart.erl @@ -40,15 +40,17 @@ %% @doc 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) -> encode_form(Parts, boundary()). @@ -141,7 +143,7 @@ mp_header(Headers, Boundary) -> BinHeaders = hackney_headers:to_binary(Headers), <<"--", Boundary/binary, "\r\n", BinHeaders/binary >>. -%% @doc return the boundary ennding a multipart +%% @doc return the boundary ending a multipart mp_eof(Boundary) -> <<"--", Boundary/binary, "--\r\n">>. @@ -156,14 +158,16 @@ part(Content, Headers, Boundary) -> %% 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. +%% len_mp_stream(Parts, Boundary) -> Size = lists:foldl(fun ({file, Path}, AccSize) ->