Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

272 lines (126 sloc) 7.304 kb

Module hackney

Function Index

body/1 Return the full body sent with the response.
body/2 Return the full body sent with the response as long as the body length doesn't go over MaxLength.
close/1 close the client.
connect/1 connect a socket and create a client state.
connect/3
connect/4
pool/1 get current pool pid or name used by a client if needed.
request/1 make a request.
request/2 make a request.
request/3 make a request.
request/4 make a request.
request/5 make a request.
send_request/2 send a request using the current client state.
set_sockopts/2 add set sockets options in the client.
skip_body/1 skip the full body.
start/0 Start the couchbeam process.
start_pool/2 start a pool.
start_response/1 start a response.
stop/0 Stop the couchbeam process.
stop_pool/1 stop a pool.
stream_body/1 Stream the response body.
stream_request_body/2 stream the request body.

Function Details

body/1

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



Return the full body sent with the response.

body/2

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



Return the full body sent with the response as long as the body length doesn't go over MaxLength.

close/1

close(Client) -> any()

close the client

connect/1

connect(Client) -> any()

connect a socket and create a client state.

connect/3

connect(Transport, Host, Port) -> any()

connect/4

connect(Transport, Host, Port, Client) -> any()

pool/1

pool(Client) -> any()

get current pool pid or name used by a client if needed

request/1

request(URL::binary() | list()) -> {ok, integer(), list(), #client{}} | {error, term()}



make a request

request/2

request(Method::term(), URL::binary() | list()) -> {ok, integer(), list(), #client{}} | {error, term()}



make a request

request/3

request(Method::term(), URL::binary() | list(), Headers::list()) -> {ok, integer(), list(), #client{}} | {error, term()}



make a request

request/4

request(Method::term(), URL::binary() | list(), Headers::list(), Body::term()) -> {ok, integer(), list(), #client{}} | {error, term()}



make a request

request/5

request(Method::term(), Hackney_url::binary(), Headers::list(), Body::term(), Options0::list()) -> {ok, integer(), list(), #client{}} | {error, term()}



make a request

Args:

  • Method: method used for the request (get, post, ...)

  • Url: full url of the request

  • Headers Proplists

  • Body:

  • {form, [{K, V}, ...]}: send a form url encoded

  • {multipart, [{K, V}, ...]}: send a form using multipart

  • {file, "/path/to/file"}: to send a file

  • Bin: binary or iolist

  • Options: [{connect_options, connect_options(), {ssl_options, ssl_options()}, hackney_options()}]

  • connect_options(): The default connect_options are [binary, {active, false}, {packet, raw}]) . Vor valid options see the gen_tcp options.

  • ssl_options(): See the ssl options from the ssl module.

  • Others options are:

  • {follow_redirect, boolean}: false by default, follow a redirection

  • {max_redirect, integer}: 5 by default, the maximum of redirection for a request

  • {force_redirect, boolean}: false by default, to force the redirection even on POST

  • {proxy, proxy_options()}: to connect via a proxy.

  • insecure: to perform "insecure" SSL connections and transfers without checking the certificate

  • proxy_options()* options to connect by a proxy:

  • binary(): url to use for the proxy. Used for basic HTTP proxy

  • {Host::binary(), Port::binary}: Host and port to connect, for HTTP proxy

send_request/2

send_request(Client, Req) -> any()

send a request using the current client state

set_sockopts/2

set_sockopts(Client, Options) -> any()

add set sockets options in the client

skip_body/1

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



skip the full body. (read all the body if needed).

start/0

start() -> any()

Start the couchbeam process. Useful when testing using the shell.

start_pool/2

start_pool(Name, Options) -> any()

start a pool

start_response/1

start_response(Client::#client{}) -> {ok, integer(), list(), #client{}} | {error, term()}



start a response. Useful if you stream the body by yourself. It will fetch the status and headers of the response. and return

stop/0

stop() -> any()

Stop the couchbeam process. Useful when testing using the shell.

stop_pool/1

stop_pool(Name) -> any()

stop a pool

stream_body/1

stream_body(Client) -> any()

Stream the response body.

stream_request_body/2

stream_request_body(Body::term(), Client::#client{}) -> {ok, #client{}} | {error, term()}



stream the request body. It isued after sending a request using the request and send_request functions.

Jump to Line
Something went wrong with that request. Please try again.