Permalink
Fetching contributors…
Cannot retrieve contributors at this time
142 lines (81 sloc) 3.93 KB

Module hackney_response

module handling the response.

Data Types

response_state()


response_state() = start | waiting | on_status | on_headers | on_body

Function Index

body/1Return the full body sent with the request.
body/2Return the full body sent with the request as long as the body length doesn't go over MaxLength.
close/1
expect_response/1handle Expect header.
maybe_close/1
skip_body/1
skip_multipart/1Skip a part returned by the multipart parser.
start_response/1Start the response It parse the request lines and headers.
stream_body/1
stream_multipart/1stream a multipart response.

Function Details

body/1


body(Client::#client{}) -> {ok, binary(), #client{}} | {error, atom()}

Return the full body sent with the request.

body/2


body(MaxLength::non_neg_integer() | infinity, Client::#client{}) -> {ok, binary(), #client{}} | {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.

close/1

close(Client) -> any()

expect_response/1

expect_response(Client) -> any()

handle Expect header

maybe_close/1

maybe_close(Client) -> any()

skip_body/1


skip_body(Client::#client{}) -> {ok, #client{}} | {error, atom()}

skip_multipart/1


skip_multipart(Client) -> {ok, Client}
  • Client = #client{}

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_response/1

start_response(Client) -> any()

Start the response It parse the request lines and headers.

stream_body/1

stream_body(Client) -> any()

stream_multipart/1


stream_multipart(Client::#client{}) -> {headers, list(), #client{}} | {body, binary(), #client{}} | {eof | end_of_part | mp_mixed | mp_mixed_eof, #client{}}

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.