hackney_response (hackney v1.25.0)
View Sourcemodule handling the response
Summary
Functions
Return the full body sent with the request.
Return the full body sent with the request as long as the body length doesn't go over MaxLength.
handle Expect header
Skip a part returned by the multipart parser.
Start the response It parse the request lines and headers.
stream a multipart response
Types
Functions
-spec body(#client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}) -> {ok, binary(), #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}} | {error, atom()}.
Return the full body sent with the request.
-spec body(non_neg_integer() | infinity, #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}) -> {ok, binary(), #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}} | {error, atom()}.
Return the full body sent with the request as long as the body length doesn't go over MaxLength.
This is most useful to quickly be able to get the full body while avoiding filling your memory with huge request bodies when you're not expecting it.
When the response is larger than MaxLength, this function will return the body it received up to the last chunk, which might be a bit more than MaxLength.
handle Expect header
-spec skip_body(#client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}) -> {ok, #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}} | {skip, #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}} | {error, atom()}.
-spec skip_multipart(Client) -> {ok, Client} when Client :: #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}.
Skip a part returned by the multipart parser.
This function repeatedly calls multipart_data/1 until {end_of_part, Req} or {eof, Req} is parsed.
Start the response It parse the request lines and headers.
-spec stream_multipart(#client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}) -> {headers, list(), #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}} | {body, binary(), #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}} | {eof | end_of_part | mp_mixed | mp_mixed_eof, #client{start_time :: term(), mod_metrics :: term(), transport :: term(), host :: term(), port :: term(), netloc :: term(), options :: term(), socket :: term(), socket_ref :: term(), request_ref :: term(), dynamic :: term(), pool_handler :: term(), recv_timeout :: term(), follow_redirect :: term(), max_redirect :: term(), force_redirect :: term(), retries :: term(), redirect :: term(), location :: term(), parser :: term(), headers :: term(), state :: term(), response_state :: term(), mp_boundary :: term(), req_type :: term(), expect :: term(), async :: term(), with_body :: term(), max_body :: term(), stream_to :: term(), send_fun :: term(), body_state :: term(), multipart :: term(), req_chunk_size :: term(), buffer :: term(), partial_headers :: term(), version :: term(), clen :: term(), te :: term(), connection :: term(), method :: term(), path :: term(), ctype :: term()}}.
stream a multipart response
Use this function for multipart streaming. For each part in the response, this function returns {headers, Headers, Req} followed by a sequence of {body, Data, Req} tuples and finally {end_of_part, Req}. When there is no part to parse anymore, {eof, Req} is returned.