Browse files

update doc

  • Loading branch information...
1 parent 8746cd2 commit 51dbf5e51663eb73a99370cc83cf350eeca185b4 @benoitc committed Jun 10, 2013
View
132 README.md
@@ -1,15 +1,14 @@
-#hackney - simple HTTP client in Erlang#
+# hackney - HTTP client library in Erlang #
-
-Copyright (c) 2012 Benoît Chesneau.
+Copyright (c) 2012-2013 Benoît Chesneau.
__Version:__ 0.4.1
# hackney
-**hackney** is a simple HTTP client.
+**hackney** is an HTTP client library for Erlan.
Main features:
@@ -19,7 +18,9 @@ Main features:
- SSL support
- Keepalive handling
- basic authentication
-- stream the response
+- stream the response and the requests
+- multipart support (stramed or not)
+- chunked encoding support
- Can send files using the sendfile API
- Chunked encoding support
- Optionnal socket pool
@@ -40,10 +41,14 @@ files and documentation.
To run tests run 'make test'.
To generate doc, run 'make doc'.
-Or add it to your rebar config<pre>{deps, [
+Or add it to your rebar config
+
+```
+{deps, [
....
{hackney, ".*", {git, "git://github.com/benoitc/hackney.git", {branch, "master"}}}
-]}.</pre>
+]}.
+```
## Basic usage
@@ -56,55 +61,90 @@ hackney is an
application. You have to start it first before using all the functions.
The hackney applications will start for you the default socket pool.
-To start in the console run :<pre>$ erl -pa ebin
+To start in the console run :
+
+```
+$ erl -pa ebin
1>> hackney:start().
-ok</pre>
+ok
+```
-It will start hackney and all the application it depends:<pre>application:start(crypto),
+It will start hackney and all the application it depends:
+
+```
+application:start(crypto),
application:start(public_key),
application:start(ssl),
-application:start(hackney).</pre>
+application:start(hackney).
+```
Or add hackney to the applications member of your relase an app
### Simple request without pool
-Do a simple a requet that will return a client state:<pre>Method = get,
+Do a simple a requet that will return a client state:
+
+```
+Method = get,
URL = <<"https://friendpaste.com">>,
Headers = [],
Payload = <<>>,
Options = [],
{ok, StatusCode, RespHeaders, Client} = hackney:request(Method, URL,
Headers, Payload,
- Options).</pre>
+ Options).
+```
The request method return the tupple `{ok, StatusCode, Headers, Client}`
or `{error, Reason}`.
-If you enable the **parse_transform**, you can also do:<pre>hackney:get(URL, Headers, Payload, Options)</pre>
+If you enable the **parse_transform**, you can also do:
+
+```
+hackney:get(URL, Headers, Payload, Options)
+```
To enable parse transform add the following option to the erlang
-compiler flags:<pre>{parse_transform, hackney_transform}</pre>
+compiler flags:
+
+```
+{parse_transform, hackney_transform}
+```
+
+Alternately, you can add it to the module you wish to compile:
+
+```
+-compile([{parse_transform, hackney_transform}]).
+```
-Alternately, you can add it to the module you wish to compile:<pre>-compile([{parse_transform, hackney_transform}]).</pre>
+### Read the body
-### Read the body<pre>{ok, Body, Client1} = hackney:body(Client).</pre>
+```
+{ok, Body, Client1} = hackney:body(Client).
+```
`hackney:body/1` fetch the body. To fetch it by chunk you can use the
-`hackney:stream/body/1` function:<pre>read_body(MaxLength, Client, Acc) when MaxLength > byte_size(Acc) ->
+`hackney:stream/body/1` function:
+
+```
+read_body(MaxLength, Client, Acc) when MaxLength > byte_size(Acc) ->
case stream_body(Client) of
{ok, Data, Client2} ->
read_body(MaxLength, Client2, << Acc/binary, Data/binary >>);
{done, Client2} ->
{ok, Acc, Client2};
{error, Reason} ->
{error, Reason}
- end.</pre>
+ end.
+```
### Reuse the client object
If your connection support the keepalive you can reuse the Client
-record using the `hackney:send_request/2` function:<pre>ReqBody = << "{
+record using the `hackney:send_request/2` function:
+
+```
+ReqBody = << "{
\"id\": \"some_paste_id\",
\"rev\": \"some_revision_id\",
\"changeset\": \"changeset in unidiff format\"
@@ -115,7 +155,8 @@ NextMethod = post,
NextReq = {NextMethod, NextPath, ReqHeaders, ReqBody}
{ok, _, _, Client2} = hackney:send_request(Client1, NextReq).
{ok, Body1, Client3} = hackney:body(Client2),
-hackney:close(Client3).</pre>
+hackney:close(Client3).
+```
Here we are posting a JSON paylod to '/' on the service friendpaste to
create a paste. Then we close the client connection.
@@ -146,7 +187,10 @@ function `hackney:stream_request_body/2` to stream the request body and
The function `hackney:start_response/1` is waiting a Client with
theresponse state equal to the atom `waiting`.
-ex:<pre>ReqBody = << "{
+ex:
+
+```
+ReqBody = << "{
\"id\": \"some_paste_id2\",
\"rev\": \"some_revision_id\",
\"changeset\": \"changeset in unidiff format\"
@@ -160,34 +204,47 @@ Method = post,
{ok, Client1} = hackney:stream_request_body(ReqBody, Client),
{ok, _Status, _Headers, Client2} = hackney:start_response(Client1),
{ok, Body, Client3} = hackney:body(Client2),
-hackney:close(Client3).</pre>
+hackney:close(Client3).
+```
### Use a pool
To reuse a connection globally in your application you can also use a
socket pool. On startup, hackney launch a pool named default. To use it
-do the following:<pre>Method = get,
+do the following:
+
+```
+Method = get,
URL = <<"https://friendpaste.com">>,
Headers = [],
Payload = <<>>,
Options = [{pool, default}],
{ok, StatusCode, RespHeaders, Client} = hackney:request(Method, URL, Headers,
- Payload, Options).</pre>
+ Payload, Options).
+```
By adding the tuple `{pool, default}` to the options, hackney will use
the connections stored in that pool.
You can also use different pools in your application which will allows
-you to maintain some kind of group of connections.<pre>PoolName = mypool,
+you to maintain some kind of group of connections.
+
+```
+PoolName = mypool,
Options = [{timeout, 150000}, {pool_size, 100}],
-{ok, Pid} = hackney:start_pool(PoolName, Options),</pre>
+{ok, Pid} = hackney:start_pool(PoolName, Options),
+```
`timeout` is the time we keep alive the conneciton in the pool,
`pool_size` is the number of connections maintained in the pool. Each
connection in a pool is monitored and closed connections are removed
automatically.
-To close a pool do:<pre>hackney:stop_pool(PoolName).</pre>
+To close a pool do:
+
+```
+hackney:stop_pool(PoolName).
+```
> Note: Sometimes you want to always use the default pool in your app
> without having to set the client option each time. You can now do this
@@ -208,14 +265,18 @@ only follow 303 redirection (see other) if the method is a POST.
Last Location is stored in the client state in the `location` property.
-ex:<pre>Method = get,
+ex:
+
+```
+Method = get,
URL = "http://friendpaste.com/",
ReqHeaders = [{<<"accept-encoding">>, <<"identity">>}],
ReqBody = <<>>,
Options = [{follow_redirect, true}, {max_redirect, true}],
{ok, S, H, Client} = hackney:request(Method, URL, ReqHeaders,
ReqBody, Options),
-{ok, Body, Client1} = hackney:body(Client).</pre>
+{ok, Body, Client1} = hackney:body(Client).
+```
### Proxy a connection
@@ -233,10 +294,15 @@ issue](http://github.com/benoitc/hackney/issues).
If you want to contribute patches or improve the doc, you will need to
build hackney using the `rebar_dev.config` file. It can also be built
-using the **Makefile**:<pre>$ make dev ; # compile & get deps
-$ make devclean ; # clean all files</pre>
+using the **Makefile**:
+
+```
+$ make dev ; # compile & get deps
+$ make devclean ; # clean all files
+```
+
-##Modules##
+## Modules ##
<table width="100%" border="0" summary="list of modules">
View
134 doc/README.md
@@ -1,15 +1,14 @@
-#hackney - simple HTTP client in Erlang#
+# hackney - HTTP client library in Erlang #
+Copyright (c) 2012-2013 Benoît Chesneau.
-Copyright (c) 2012 Benoît Chesneau.
-
-__Version:__ 0.4
+__Version:__ 0.4.1
# hackney
-**hackney** is a simple HTTP client.
+**hackney** is an HTTP client library for Erlan.
Main features:
@@ -19,7 +18,9 @@ Main features:
- SSL support
- Keepalive handling
- basic authentication
-- stream the response
+- stream the response and the requests
+- multipart support (stramed or not)
+- chunked encoding support
- Can send files using the sendfile API
- Chunked encoding support
- Optionnal socket pool
@@ -40,10 +41,14 @@ files and documentation.
To run tests run 'make test'.
To generate doc, run 'make doc'.
-Or add it to your rebar config<pre>{deps, [
+Or add it to your rebar config
+
+```
+{deps, [
....
{hackney, ".*", {git, "git://github.com/benoitc/hackney.git", {branch, "master"}}}
-]}.</pre>
+]}.
+```
## Basic usage
@@ -56,55 +61,90 @@ hackney is an
application. You have to start it first before using all the functions.
The hackney applications will start for you the default socket pool.
-To start in the console run :<pre>$ erl -pa ebin
+To start in the console run :
+
+```
+$ erl -pa ebin
1>> hackney:start().
-ok</pre>
+ok
+```
-It will start hackney and all the application it depends:<pre>application:start(crypto),
+It will start hackney and all the application it depends:
+
+```
+application:start(crypto),
application:start(public_key),
application:start(ssl),
-application:start(hackney).</pre>
+application:start(hackney).
+```
Or add hackney to the applications member of your relase an app
### Simple request without pool
-Do a simple a requet that will return a client state:<pre>Method = get,
+Do a simple a requet that will return a client state:
+
+```
+Method = get,
URL = <<"https://friendpaste.com">>,
Headers = [],
Payload = <<>>,
Options = [],
{ok, StatusCode, RespHeaders, Client} = hackney:request(Method, URL,
Headers, Payload,
- Options).</pre>
+ Options).
+```
The request method return the tupple `{ok, StatusCode, Headers, Client}`
or `{error, Reason}`.
-If you enable the **parse_transform**, you can also do:<pre>hackney:get(URL, Headers, Payload, Options)</pre>
+If you enable the **parse_transform**, you can also do:
+
+```
+hackney:get(URL, Headers, Payload, Options)
+```
To enable parse transform add the following option to the erlang
-compiler flags:<pre>{parse_transform, hackney_transform}</pre>
+compiler flags:
+
+```
+{parse_transform, hackney_transform}
+```
+
+Alternately, you can add it to the module you wish to compile:
+
+```
+-compile([{parse_transform, hackney_transform}]).
+```
-Alternately, you can add it to the module you wish to compile:<pre>-compile([{parse_transform, hackney_transform}]).</pre>
+### Read the body
-### Read the body<pre>{ok, Body, Client1} = hackney:body(Client).</pre>
+```
+{ok, Body, Client1} = hackney:body(Client).
+```
`hackney:body/1` fetch the body. To fetch it by chunk you can use the
-`hackney:stream/body/1` function:<pre>read_body(MaxLength, Client, Acc) when MaxLength > byte_size(Acc) ->
+`hackney:stream/body/1` function:
+
+```
+read_body(MaxLength, Client, Acc) when MaxLength > byte_size(Acc) ->
case stream_body(Client) of
{ok, Data, Client2} ->
read_body(MaxLength, Client2, << Acc/binary, Data/binary >>);
{done, Client2} ->
{ok, Acc, Client2};
{error, Reason} ->
{error, Reason}
- end.</pre>
+ end.
+```
### Reuse the client object
If your connection support the keepalive you can reuse the Client
-record using the `hackney:send_request/2` function:<pre>ReqBody = << "{
+record using the `hackney:send_request/2` function:
+
+```
+ReqBody = << "{
\"id\": \"some_paste_id\",
\"rev\": \"some_revision_id\",
\"changeset\": \"changeset in unidiff format\"
@@ -115,7 +155,8 @@ NextMethod = post,
NextReq = {NextMethod, NextPath, ReqHeaders, ReqBody}
{ok, _, _, Client2} = hackney:send_request(Client1, NextReq).
{ok, Body1, Client3} = hackney:body(Client2),
-hackney:close(Client3).</pre>
+hackney:close(Client3).
+```
Here we are posting a JSON paylod to '/' on the service friendpaste to
create a paste. Then we close the client connection.
@@ -146,7 +187,10 @@ function `hackney:stream_request_body/2` to stream the request body and
The function `hackney:start_response/1` is waiting a Client with
theresponse state equal to the atom `waiting`.
-ex:<pre>ReqBody = << "{
+ex:
+
+```
+ReqBody = << "{
\"id\": \"some_paste_id2\",
\"rev\": \"some_revision_id\",
\"changeset\": \"changeset in unidiff format\"
@@ -160,34 +204,47 @@ Method = post,
{ok, Client1} = hackney:stream_request_body(ReqBody, Client),
{ok, _Status, _Headers, Client2} = hackney:start_response(Client1),
{ok, Body, Client3} = hackney:body(Client2),
-hackney:close(Client3).</pre>
+hackney:close(Client3).
+```
### Use a pool
To reuse a connection globally in your application you can also use a
socket pool. On startup, hackney launch a pool named default. To use it
-do the following:<pre>Method = get,
+do the following:
+
+```
+Method = get,
URL = <<"https://friendpaste.com">>,
Headers = [],
Payload = <<>>,
Options = [{pool, default}],
{ok, StatusCode, RespHeaders, Client} = hackney:request(Method, URL, Headers,
- Payload, Options).</pre>
+ Payload, Options).
+```
By adding the tuple `{pool, default}` to the options, hackney will use
the connections stored in that pool.
You can also use different pools in your application which will allows
-you to maintain some kind of group of connections.<pre>PoolName = mypool,
+you to maintain some kind of group of connections.
+
+```
+PoolName = mypool,
Options = [{timeout, 150000}, {pool_size, 100}],
-{ok, Pid} = hackney:start_pool(PoolName, Options),</pre>
+{ok, Pid} = hackney:start_pool(PoolName, Options),
+```
`timeout` is the time we keep alive the conneciton in the pool,
`pool_size` is the number of connections maintained in the pool. Each
connection in a pool is monitored and closed connections are removed
automatically.
-To close a pool do:<pre>hackney:stop_pool(PoolName).</pre>
+To close a pool do:
+
+```
+hackney:stop_pool(PoolName).
+```
> Note: Sometimes you want to always use the default pool in your app
> without having to set the client option each time. You can now do this
@@ -208,14 +265,18 @@ only follow 303 redirection (see other) if the method is a POST.
Last Location is stored in the client state in the `location` property.
-ex:<pre>Method = get,
+ex:
+
+```
+Method = get,
URL = "http://friendpaste.com/",
ReqHeaders = [{<<"accept-encoding">>, <<"identity">>}],
ReqBody = <<>>,
Options = [{follow_redirect, true}, {max_redirect, true}],
{ok, S, H, Client} = hackney:request(Method, URL, ReqHeaders,
ReqBody, Options),
-{ok, Body, Client1} = hackney:body(Client).</pre>
+{ok, Body, Client1} = hackney:body(Client).
+```
### Proxy a connection
@@ -233,10 +294,15 @@ issue](http://github.com/benoitc/hackney/issues).
If you want to contribute patches or improve the doc, you will need to
build hackney using the `rebar_dev.config` file. It can also be built
-using the **Makefile**:<pre>$ make dev ; # compile & get deps
-$ make devclean ; # clean all files</pre>
+using the **Makefile**:
+
+```
+$ make dev ; # compile & get deps
+$ make devclean ; # clean all files
+```
+
-##Modules##
+## Modules ##
<table width="100%" border="0" summary="list of modules">
View
1 doc/edoc-info
@@ -1,3 +1,4 @@
+%% encoding: UTF-8
{application,hackney}.
{packages,[]}.
{modules,[hackney,hackney_app,hackney_deps,hackney_form,hackney_headers,
View
206 doc/hackney.md
@@ -1,13 +1,13 @@
-#Module hackney#
+# Module hackney #
* [Function Index](#index)
* [Function Details](#functions)
<a name="index"></a>
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#body-1">body/1</a></td><td>Return the full body sent with the response.</td></tr><tr><td valign="top"><a href="#body-2">body/2</a></td><td>Return the full body sent with the response as long as the body
@@ -16,6 +16,7 @@ Possible value are :
<ul>
<li><code>eof</code>: end the multipart request</li>
<li><code>{Id, {File, FileName}}</code>: to stream a file</li>
+%% <li><code>{Id, {File, FileName, FileOptions}}</code>: to stream a file</li>
<li><code>{data, {start, Id, DileName, ContentType}}</code>: to start to stream
arbitrary binary content</li>
<li><code>{data, Bin}`: send a binary. Use it only after emitting a
@@ -26,123 +27,156 @@ the multipart request</li>
boundary</li>
<li><code>{Id, Value}</code>: send an arbitrary value as a boundary. Filename and
Id are identique</li>
+</ul>
+File options can be:
+<ul>
+<li><code>{offset, Offset}</code>: start to send file from this offset</li>
+<li><code>{bytes, Bytes}</code>: number of bytes to send</li>
+<li><code>{chunk_size, ChunkSize}</code>: the size of the chunk to send</li>
</ul></td></tr><tr><td valign="top"><a href="#stream_request_body-2">stream_request_body/2</a></td><td>stream the request body.</td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="body-1"></a>
-###body/1##
+### body/1 ###
+
+<pre><code>
+body(Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}
+</code></pre>
-<pre>body(Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}</pre>
<br></br>
-Return the full body sent with the response.<a name="body-2"></a>
+Return the full body sent with the response.
+<a name="body-2"></a>
+
+### body/2 ###
-###body/2##
+<pre><code>
+body(MaxLength::non_neg_integer() | infinity, Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}
+</code></pre>
-<pre>body(MaxLength::non_neg_integer() | infinity, Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}</pre>
<br></br>
Return the full body sent with the response as long as the body
-length doesn't go over MaxLength.<a name="close-1"></a>
-
-###close/1##
+length doesn't go over MaxLength.
+<a name="close-1"></a>
+### close/1 ###
`close(Client) -> any()`
-close the client<a name="connect-1"></a>
-
-###connect/1##
+close the client
+<a name="connect-1"></a>
+### connect/1 ###
`connect(Client) -> any()`
-connect a socket and create a client state.<a name="connect-3"></a>
-
-###connect/3##
+connect a socket and create a client state.
+<a name="connect-3"></a>
+### connect/3 ###
`connect(Transport, Host, Port) -> any()`
-<a name="connect-4"></a>
-###connect/4##
+<a name="connect-4"></a>
+### connect/4 ###
`connect(Transport, Host, Port, Client) -> any()`
-<a name="end_stream_request_body-1"></a>
-###end_stream_request_body/1##
+<a name="end_stream_request_body-1"></a>
+### end_stream_request_body/1 ###
`end_stream_request_body(Client) -> any()`
-end streaming the request body.<a name="pool-1"></a>
-
-###pool/1##
+end streaming the request body.
+<a name="pool-1"></a>
+### pool/1 ###
`pool(Client) -> any()`
-get current pool pid or name used by a client if needed<a name="request-1"></a>
+get current pool pid or name used by a client if needed
+<a name="request-1"></a>
-###request/1##
+### request/1 ###
-<pre>request(URL::binary() | list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}</pre>
+<pre><code>
+request(URL::binary() | list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}
+</code></pre>
+
<br></br>
-make a request<a name="request-2"></a>
+make a request
+<a name="request-2"></a>
+
+### request/2 ###
-###request/2##
+<pre><code>
+request(Method::term(), URL::binary() | list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}
+</code></pre>
-<pre>request(Method::term(), URL::binary() | list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}</pre>
<br></br>
-make a request<a name="request-3"></a>
+make a request
+<a name="request-3"></a>
+
+### request/3 ###
-###request/3##
+<pre><code>
+request(Method::term(), URL::binary() | list(), Headers::list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}
+</code></pre>
-<pre>request(Method::term(), URL::binary() | list(), Headers::list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}</pre>
<br></br>
-make a request<a name="request-4"></a>
+make a request
+<a name="request-4"></a>
-###request/4##
+### request/4 ###
-<pre>request(Method::term(), URL::binary() | list(), Headers::list(), Body::term()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}</pre>
+<pre><code>
+request(Method::term(), URL::binary() | list(), Headers::list(), Body::term()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}
+</code></pre>
+
<br></br>
-make a request<a name="request-5"></a>
+make a request
+<a name="request-5"></a>
-###request/5##
+### request/5 ###
-<pre>request(Method::term(), Hackney_url::binary(), Headers::list(), Body::term(), Options0::list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}</pre>
-<br></br>
+<pre><code>
+request(Method::term(), Hackney_url::binary(), Headers::list(), Body::term(), Options0::list()) -&gt; {ok, integer(), list(), #client{}} | {error, term()}
+</code></pre>
+<br></br>
make a request
+
Args:
* <strong>Method</strong>
@@ -197,6 +231,9 @@ redirection even on POST
* insecure: to perform "insecure" SSL connections and
transfers without checking the certificate
+* {connect_timeout, infinity | integer()}: timeout used when
+estabilishing a connection, in milliseconds. Default is 8000
+
* {recv_timeout, infinity | integer()}: timeout used when
receiving a connection. Default is infinity
@@ -207,7 +244,6 @@ receiving a connection. Default is infinity
* `proxy_options()`: options to connect by a proxy:
-
* binary(): url to use for the proxy. Used for basic HTTP
proxy
@@ -216,79 +252,88 @@ for HTTP proxy
-<a name="send_request-2"></a>
-###send_request/2##
+<a name="send_request-2"></a>
-`send_request(Client, Req) -> any()`
+### send_request/2 ###
-send a request using the current client state<a name="set_sockopts-2"></a>
+`send_request(Client, Req) -> any()`
-###set_sockopts/2##
+send a request using the current client state
+<a name="set_sockopts-2"></a>
+### set_sockopts/2 ###
`set_sockopts(Client, Options) -> any()`
-add set sockets options in the client<a name="skip_body-1"></a>
+add set sockets options in the client
+<a name="skip_body-1"></a>
-###skip_body/1##
+### skip_body/1 ###
-<pre>skip_body(Client::#client{}) -&gt; {ok, #client{}} | {error, atom()}</pre>
-<br></br>
+<pre><code>
+skip_body(Client::#client{}) -&gt; {ok, #client{}} | {error, atom()}
+</code></pre>
+<br></br>
-skip the full body. (read all the body if needed).<a name="start-0"></a>
-###start/0##
+skip the full body. (read all the body if needed).
+<a name="start-0"></a>
+### start/0 ###
`start() -> any()`
-Start the couchbeam process. Useful when testing using the shell.<a name="start_pool-2"></a>
-
-###start_pool/2##
+Start the couchbeam process. Useful when testing using the shell.
+<a name="start_pool-2"></a>
+### start_pool/2 ###
`start_pool(Name, Options) -> any()`
-start a pool<a name="start_response-1"></a>
+start a pool
+<a name="start_response-1"></a>
-###start_response/1##
+### start_response/1 ###
-<pre>start_response(Client::#client{}) -&gt; {ok, integer(), list(), #client{}} | {error, term()}</pre>
+<pre><code>
+start_response(Client::#client{}) -&gt; {ok, integer(), list(), #client{}} | {error, term()}
+</code></pre>
+
<br></br>
start a response.
Useful if you stream the body by yourself. It will fetch the status
-and headers of the response. and return<a name="stop-0"></a>
-
-###stop/0##
+and headers of the response. and return
+<a name="stop-0"></a>
+### stop/0 ###
`stop() -> any()`
-Stop the couchbeam process. Useful when testing using the shell.<a name="stop_pool-1"></a>
-
-###stop_pool/1##
+Stop the couchbeam process. Useful when testing using the shell.
+<a name="stop_pool-1"></a>
+### stop_pool/1 ###
`stop_pool(Name) -> any()`
-stop a pool<a name="stream_body-1"></a>
-
-###stream_body/1##
+stop a pool
+<a name="stream_body-1"></a>
+### stream_body/1 ###
`stream_body(Client) -> any()`
-Stream the response body.<a name="stream_multipart_request-2"></a>
-
-###stream_multipart_request/2##
+Stream the response body.
+<a name="stream_multipart_request-2"></a>
+### stream_multipart_request/2 ###
`stream_multipart_request(Body, Client) -> any()`
@@ -299,6 +344,8 @@ Possible value are :
* `{Id, {File, FileName}}`: to stream a file
+%% * `{Id, {File, FileName, FileOptions}}`: to stream a file
+
* `{data, {start, Id, DileName, ContentType}}`: to start to stream
arbitrary binary content
@@ -313,14 +360,27 @@ boundary
* `{Id, Value}`: send an arbitrary value as a boundary. Filename and
Id are identique
+
+File options can be:
+
+* `{offset, Offset}`: start to send file from this offset
+
+* `{bytes, Bytes}`: number of bytes to send
+
+* `{chunk_size, ChunkSize}`: the size of the chunk to send
+
+
<a name="stream_request_body-2"></a>
-###stream_request_body/2##
+### stream_request_body/2 ###
+
+<pre><code>
+stream_request_body(Body::term(), Client::#client{}) -&gt; {ok, #client{}} | {error, term()}
+</code></pre>
-<pre>stream_request_body(Body::term(), Client::#client{}) -&gt; {ok, #client{}} | {error, term()}</pre>
<br></br>
stream the request body. It isued after sending a request using
-the `request` and `send_request` functions.
+the `request` and `send_request` functions.
View
22 doc/hackney_app.md
@@ -1,40 +1,40 @@
-#Module hackney_app#
+# Module hackney_app #
* [Function Index](#index)
* [Function Details](#functions)
+__Behaviours:__ [`application`](application.md).
+<a name="index"></a>
-__Behaviours:__ [`application`](application.md).<a name="index"></a>
-
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#ensure_deps_started-0">ensure_deps_started/0</a></td><td></td></tr><tr><td valign="top"><a href="#start-2">start/2</a></td><td></td></tr><tr><td valign="top"><a href="#stop-1">stop/1</a></td><td></td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="ensure_deps_started-0"></a>
-###ensure_deps_started/0##
-
+### ensure_deps_started/0 ###
`ensure_deps_started() -> any()`
-<a name="start-2"></a>
-###start/2##
+<a name="start-2"></a>
+### start/2 ###
`start(StartType, StartArgs) -> any()`
-<a name="stop-1"></a>
-###stop/1##
+<a name="stop-1"></a>
+### stop/1 ###
`stop(State) -> any()`
+
View
85 doc/hackney_deps.md
@@ -1,13 +1,13 @@
-#Module hackney_deps#
+# Module hackney_deps #
* [Function Index](#index)
* [Function Details](#functions)
<a name="index"></a>
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#deps_on_path-0">deps_on_path/0</a></td><td>List of project dependencies on the path.</td></tr><tr><td valign="top"><a href="#ensure-0">ensure/0</a></td><td>Ensure that the ebin and include paths for dependencies of
@@ -18,85 +18,116 @@ code path.</td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="deps_on_path-0"></a>
-###deps_on_path/0##
+### deps_on_path/0 ###
-<pre>deps_on_path() -&gt; [ProjNameAndVers]</pre>
+<pre><code>
+deps_on_path() -&gt; [ProjNameAndVers]
+</code></pre>
+
<br></br>
-List of project dependencies on the path.<a name="ensure-0"></a>
+List of project dependencies on the path.
+<a name="ensure-0"></a>
+
+### ensure/0 ###
-###ensure/0##
+<pre><code>
+ensure() -&gt; ok
+</code></pre>
-<pre>ensure() -&gt; ok</pre>
<br></br>
Ensure that the ebin and include paths for dependencies of
this application are on the code path. Equivalent to
-ensure(?Module).<a name="ensure-1"></a>
+ensure(?Module).
+<a name="ensure-1"></a>
-###ensure/1##
+### ensure/1 ###
-<pre>ensure(Module) -&gt; ok</pre>
+<pre><code>
+ensure(Module) -&gt; ok
+</code></pre>
+
<br></br>
Ensure that all ebin and include paths for dependencies
-of the application for Module are on the code path.<a name="get_base_dir-0"></a>
+of the application for Module are on the code path.
+<a name="get_base_dir-0"></a>
+
+### get_base_dir/0 ###
-###get_base_dir/0##
+<pre><code>
+get_base_dir() -&gt; string()
+</code></pre>
-<pre>get_base_dir() -&gt; string()</pre>
<br></br>
Return the application directory for this application. Equivalent to
-get_base_dir(?MODULE).<a name="get_base_dir-1"></a>
+get_base_dir(?MODULE).
+<a name="get_base_dir-1"></a>
-###get_base_dir/1##
+### get_base_dir/1 ###
-<pre>get_base_dir(Module) -&gt; string()</pre>
+<pre><code>
+get_base_dir(Module) -&gt; string()
+</code></pre>
+
<br></br>
Return the application directory for Module. It assumes Module is in
-a standard OTP layout application in the ebin or src directory.<a name="local_path-1"></a>
+a standard OTP layout application in the ebin or src directory.
+<a name="local_path-1"></a>
+
+### local_path/1 ###
-###local_path/1##
+<pre><code>
+local_path(Components) -&gt; string()
+</code></pre>
-<pre>local_path(Components) -&gt; string()</pre>
<br></br>
Return an application-relative directory for this application.
-Equivalent to local_path(Components, ?MODULE).<a name="local_path-2"></a>
+Equivalent to local_path(Components, ?MODULE).
+<a name="local_path-2"></a>
-###local_path/2##
+### local_path/2 ###
-<pre>local_path(Components::[string()], Module) -&gt; string()</pre>
+<pre><code>
+local_path(Components::[string()], Module) -&gt; string()
+</code></pre>
+
<br></br>
-Return an application-relative directory from Module's application.<a name="new_siblings-1"></a>
+Return an application-relative directory from Module's application.
+<a name="new_siblings-1"></a>
+
+### new_siblings/1 ###
-###new_siblings/1##
+<pre><code>
+new_siblings(Module) -&gt; [Dir]
+</code></pre>
-<pre>new_siblings(Module) -&gt; [Dir]</pre>
<br></br>
Find new siblings paths relative to Module that aren't already on the
-code path.
+code path.
View
15 doc/hackney_form.md
@@ -1,6 +1,6 @@
-#Module hackney_form#
+# Module hackney_form #
* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
@@ -10,28 +10,27 @@ module to encode/decode forms.
<a name="index"></a>
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#decode_form-1">decode_form/1</a></td><td></td></tr><tr><td valign="top"><a href="#encode_form-1">encode_form/1</a></td><td>encode a list of properties in a form.</td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="decode_form-1"></a>
-###decode_form/1##
-
+### decode_form/1 ###
`decode_form(Bin) -> any()`
-<a name="encode_form-1"></a>
-###encode_form/1##
+<a name="encode_form-1"></a>
+### encode_form/1 ###
`encode_form(KVs) -> any()`
-encode a list of properties in a form.
+encode a list of properties in a form.
View
42 doc/hackney_headers.md
@@ -1,82 +1,82 @@
-#Module hackney_headers#
+# Module hackney_headers #
* [Function Index](#index)
* [Function Details](#functions)
<a name="index"></a>
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#delete-2">delete/2</a></td><td></td></tr><tr><td valign="top"><a href="#fold-3">fold/3</a></td><td></td></tr><tr><td valign="top"><a href="#get_value-2">get_value/2</a></td><td></td></tr><tr><td valign="top"><a href="#get_value-3">get_value/3</a></td><td></td></tr><tr><td valign="top"><a href="#insert-3">insert/3</a></td><td></td></tr><tr><td valign="top"><a href="#new-0">new/0</a></td><td></td></tr><tr><td valign="top"><a href="#new-1">new/1</a></td><td></td></tr><tr><td valign="top"><a href="#to_list-1">to_list/1</a></td><td></td></tr><tr><td valign="top"><a href="#update-2">update/2</a></td><td></td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="delete-2"></a>
-###delete/2##
-
+### delete/2 ###
`delete(Key, Headers) -> any()`
-<a name="fold-3"></a>
-###fold/3##
+<a name="fold-3"></a>
+### fold/3 ###
`fold(Fun, Acc0, Headers) -> any()`
-<a name="get_value-2"></a>
-###get_value/2##
+<a name="get_value-2"></a>
+### get_value/2 ###
`get_value(Key, Headers) -> any()`
-<a name="get_value-3"></a>
-###get_value/3##
+<a name="get_value-3"></a>
+### get_value/3 ###
`get_value(Key, Headers, Default) -> any()`
-<a name="insert-3"></a>
-###insert/3##
+<a name="insert-3"></a>
+### insert/3 ###
`insert(Key, Value, Headers) -> any()`
-<a name="new-0"></a>
-###new/0##
+<a name="new-0"></a>
+### new/0 ###
`new() -> any()`
-<a name="new-1"></a>
-###new/1##
+<a name="new-1"></a>
+### new/1 ###
`new(D) -> any()`
-<a name="to_list-1"></a>
-###to_list/1##
+<a name="to_list-1"></a>
+### to_list/1 ###
`to_list(Headers) -> any()`
-<a name="update-2"></a>
-###update/2##
+<a name="update-2"></a>
+### update/2 ###
`update(Headers, KVs) -> any()`
+
View
24 doc/hackney_multipart.md
@@ -1,6 +1,6 @@
-#Module hackney_multipart#
+# Module hackney_multipart #
* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
@@ -10,41 +10,41 @@ module to encode/decode forms.
<a name="index"></a>
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#boundary-0">boundary/0</a></td><td></td></tr><tr><td valign="top"><a href="#decode_form-1">decode_form/1</a></td><td></td></tr><tr><td valign="top"><a href="#encode_form-1">encode_form/1</a></td><td>encode a list of properties in a form.</td></tr><tr><td valign="top"><a href="#stream-2">stream/2</a></td><td></td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="boundary-0"></a>
-###boundary/0##
-
+### boundary/0 ###
`boundary() -> any()`
-<a name="decode_form-1"></a>
-###decode_form/1##
+<a name="decode_form-1"></a>
+### decode_form/1 ###
`decode_form(X1) -> any()`
-<a name="encode_form-1"></a>
-###encode_form/1##
+<a name="encode_form-1"></a>
+### encode_form/1 ###
`encode_form(KVs) -> any()`
-encode a list of properties in a form.<a name="stream-2"></a>
-
-###stream/2##
+encode a list of properties in a form.
+<a name="stream-2"></a>
+### stream/2 ###
`stream(X1, Client) -> any()`
+
View
105 doc/hackney_pool.md
@@ -1,16 +1,16 @@
-#Module hackney_pool#
+# Module hackney_pool #
* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
pool of sockets connections.
+__Behaviours:__ [`gen_server`](gen_server.md).
+<a name="index"></a>
-__Behaviours:__ [`gen_server`](gen_server.md).<a name="index"></a>
-
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#child_spec-2">child_spec/2</a></td><td>return a child spec suitable for embeding your pool in the
@@ -19,141 +19,140 @@ supervisor.</td></tr><tr><td valign="top"><a href="#code_change-3">code_change/3
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="child_spec-2"></a>
-###child_spec/2##
-
+### child_spec/2 ###
`child_spec(Name, Options0) -> any()`
return a child spec suitable for embeding your pool in the
-supervisor<a name="code_change-3"></a>
-
-###code_change/3##
+supervisor
+<a name="code_change-3"></a>
+### code_change/3 ###
`code_change(OldVsn, State, Extra) -> any()`
-<a name="handle_call-3"></a>
-###handle_call/3##
+<a name="handle_call-3"></a>
+### handle_call/3 ###
`handle_call(X1, From, State) -> any()`
-<a name="handle_cast-2"></a>
-###handle_cast/2##
+<a name="handle_cast-2"></a>
+### handle_cast/2 ###
`handle_cast(Msg, State) -> any()`
-<a name="handle_info-2"></a>
-###handle_info/2##
+<a name="handle_info-2"></a>
+### handle_info/2 ###
`handle_info(X1, State) -> any()`
-<a name="init-1"></a>
-###init/1##
+<a name="init-1"></a>
+### init/1 ###
`init(Options) -> any()`
-<a name="max_poolsize-1"></a>
-###max_poolsize/1##
+<a name="max_poolsize-1"></a>
+### max_poolsize/1 ###
`max_poolsize(PidOrName) -> any()`
-get max pool size<a name="pool_size-1"></a>
-
-###pool_size/1##
+get max pool size
+<a name="pool_size-1"></a>
+### pool_size/1 ###
`pool_size(PidOrName) -> any()`
-get total pool size<a name="pool_size-2"></a>
-
-###pool_size/2##
+get total pool size
+<a name="pool_size-2"></a>
+### pool_size/2 ###
`pool_size(PidOrName, X2) -> any()`
-get the pool size for `{Transport, Host0, Port}`<a name="release-3"></a>
-
-###release/3##
+get the pool size for `{Transport, Host0, Port}`
+<a name="release-3"></a>
+### release/3 ###
`release(PidOrName, X2, Socket) -> any()`
-release a socket in the pool<a name="set_poolsize-2"></a>
-
-###set_poolsize/2##
+release a socket in the pool
+<a name="set_poolsize-2"></a>
+### set_poolsize/2 ###
`set_poolsize(PidOrName, NewSize) -> any()`
-change the pool size<a name="set_timeout-2"></a>
-
-###set_timeout/2##
+change the pool size
+<a name="set_timeout-2"></a>
+### set_timeout/2 ###
`set_timeout(PidOrName, NewTimeout) -> any()`
change the connection timeout
-<a name="socket-2"></a>
-###socket/2##
+<a name="socket-2"></a>
+### socket/2 ###
`socket(PidOrName, X2) -> any()`
-fetch a socket from the pool<a name="start_link-0"></a>
-
-###start_link/0##
+fetch a socket from the pool
+<a name="start_link-0"></a>
+### start_link/0 ###
`start_link() -> any()`
-<a name="start_link-1"></a>
-###start_link/1##
+<a name="start_link-1"></a>
+### start_link/1 ###
`start_link(Options0) -> any()`
-<a name="start_pool-2"></a>
-###start_pool/2##
+<a name="start_pool-2"></a>
+### start_pool/2 ###
`start_pool(Name, Options) -> any()`
-start a pool<a name="stop_pool-1"></a>
-
-###stop_pool/1##
+start a pool
+<a name="stop_pool-1"></a>
+### stop_pool/1 ###
`stop_pool(Name) -> any()`
-stop a pool<a name="terminate-2"></a>
-
-###terminate/2##
+stop a pool
+<a name="terminate-2"></a>
+### terminate/2 ###
`terminate(Reason, State) -> any()`
-<a name="timeout-1"></a>
-###timeout/1##
+<a name="timeout-1"></a>
+### timeout/1 ###
`timeout(PidOrName) -> any()`
-get timeout
+get timeout
View
37 doc/hackney_request.md
@@ -1,61 +1,64 @@
-#Module hackney_request#
+# Module hackney_request #
+* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
+module handling the request.
+
<a name="index"></a>
-##Function Index##
+## Function Index ##
-<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#end_stream_body-1">end_stream_body/1</a></td><td></td></tr><tr><td valign="top"><a href="#perform-2">perform/2</a></td><td></td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td></td></tr><tr><td valign="top"><a href="#send_chunk-2">send_chunk/2</a></td><td></td></tr><tr><td valign="top"><a href="#sendfile-2">sendfile/2</a></td><td></td></tr><tr><td valign="top"><a href="#stream_body-2">stream_body/2</a></td><td></td></tr></table>
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#end_stream_body-1">end_stream_body/1</a></td><td></td></tr><tr><td valign="top"><a href="#perform-2">perform/2</a></td><td></td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td></td></tr><tr><td valign="top"><a href="#send_chunk-2">send_chunk/2</a></td><td></td></tr><tr><td valign="top"><a href="#sendfile-3">sendfile/3</a></td><td></td></tr><tr><td valign="top"><a href="#stream_body-2">stream_body/2</a></td><td></td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="end_stream_body-1"></a>
-###end_stream_body/1##
-
+### end_stream_body/1 ###
`end_stream_body(Client) -> any()`
-<a name="perform-2"></a>
-###perform/2##
+<a name="perform-2"></a>
+### perform/2 ###
`perform(Client0, X2) -> any()`
-<a name="send-2"></a>
-###send/2##
+<a name="send-2"></a>
+### send/2 ###
`send(Client, Data) -> any()`
-<a name="send_chunk-2"></a>
-###send_chunk/2##
+<a name="send_chunk-2"></a>
+### send_chunk/2 ###
`send_chunk(Client, Data) -> any()`
-<a name="sendfile-2"></a>
-###sendfile/2##
+<a name="sendfile-3"></a>
+### sendfile/3 ###
-`sendfile(FileName, Client) -> any()`
+`sendfile(FileName, Opts, Client) -> any()`
-<a name="stream_body-2"></a>
-###stream_body/2##
+<a name="stream_body-2"></a>
+### stream_body/2 ###
`stream_body(Func, Client) -> any()`
+
View
71 doc/hackney_response.md
@@ -1,13 +1,16 @@
-#Module hackney_response#
+# Module hackney_response #
+* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
+module handling the response.
+
<a name="index"></a>
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#body-1">body/1</a></td><td>Return the full body sent with the request.</td></tr><tr><td valign="top"><a href="#body-2">body/2</a></td><td>Return the full body sent with the request as long as the body
@@ -16,82 +19,98 @@ length doesn't go over MaxLength.</td></tr><tr><td valign="top"><a href="#close-
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="body-1"></a>
-###body/1##
+### body/1 ###
+
+<pre><code>
+body(Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}
+</code></pre>
-<pre>body(Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}</pre>
<br></br>
-Return the full body sent with the request.<a name="body-2"></a>
+Return the full body sent with the request.
+<a name="body-2"></a>
-###body/2##
+### body/2 ###
-<pre>body(MaxLength::non_neg_integer() | infinity, Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}</pre>
-<br></br>
+<pre><code>
+body(MaxLength::non_neg_integer() | infinity, Client::#client{}) -&gt; {ok, binary(), #client{}} | {error, atom()}
+</code></pre>
+<br></br>
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.<a name="close-1"></a>
+not expecting it.
+
-###close/1##
+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.
+<a name="close-1"></a>
+### close/1 ###
`close(Client) -> any()`
+
<a name="skip_body-1"></a>
-###skip_body/1##
+### skip_body/1 ###
+
+<pre><code>
+skip_body(Client::#client{}) -&gt; {ok, #client{}} | {error, atom()}
+</code></pre>
-<pre>skip_body(Client::#client{}) -&gt; {ok, #client{}} | {error, atom()}</pre>
<br></br>
-<a name="start_response-1"></a>
-###start_response/1##
+<a name="start_response-1"></a>
+### start_response/1 ###
`start_response(Client) -> any()`
-Start the response It parse the request lines and headers.<a name="stream_body-1"></a>
-
-###stream_body/1##
+Start the response It parse the request lines and headers.
+<a name="stream_body-1"></a>
+### stream_body/1 ###
`stream_body(Client) -> any()`
-<a name="stream_header-1"></a>
-###stream_header/1##
+<a name="stream_header-1"></a>
+### stream_header/1 ###
`stream_header(Client) -> any()`
-<a name="stream_headers-1"></a>
-###stream_headers/1##
+<a name="stream_headers-1"></a>
+### stream_headers/1 ###
`stream_headers(Client) -> any()`
-fetch all headers<a name="stream_status-1"></a>
-
-###stream_status/1##
+fetch all headers
+<a name="stream_status-1"></a>
+### stream_status/1 ###
`stream_status(Client) -> any()`
-parse the status line
+parse the status line
View
92 doc/hackney_ssl_transport.md
@@ -1,111 +1,145 @@
-#Module hackney_ssl_transport#
+# Module hackney_ssl_transport #
* [Function Index](#index)
* [Function Details](#functions)
<a name="index"></a>
-##Function Index##
+## Function Index ##
-<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#close-1">close/1</a></td><td>Close a TCP socket.</td></tr><tr><td valign="top"><a href="#connect-3">connect/3</a></td><td></td></tr><tr><td valign="top"><a href="#controlling_process-2">controlling_process/2</a></td><td>Assign a new controlling process <em>Pid</em> to <em>Socket</em>.</td></tr><tr><td valign="top"><a href="#peername-1">peername/1</a></td><td>Return the address and port for the other end of a connection.</td></tr><tr><td valign="top"><a href="#recv-2">recv/2</a></td><td></td></tr><tr><td valign="top"><a href="#recv-3">recv/3</a></td><td>Receive a packet from a socket in passive mode.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Send a packet on a socket.</td></tr><tr><td valign="top"><a href="#setopts-2">setopts/2</a></td><td>Set one or more options for a socket.</td></tr><tr><td valign="top"><a href="#sockname-1">sockname/1</a></td><td>Get the local address and port of a socket.</td></tr></table>
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#close-1">close/1</a></td><td>Close a TCP socket.</td></tr><tr><td valign="top"><a href="#connect-3">connect/3</a></td><td></td></tr><tr><td valign="top"><a href="#connect-4">connect/4</a></td><td></td></tr><tr><td valign="top"><a href="#controlling_process-2">controlling_process/2</a></td><td>Assign a new controlling process <em>Pid</em> to <em>Socket</em>.</td></tr><tr><td valign="top"><a href="#peername-1">peername/1</a></td><td>Return the address and port for the other end of a connection.</td></tr><tr><td valign="top"><a href="#recv-2">recv/2</a></td><td></td></tr><tr><td valign="top"><a href="#recv-3">recv/3</a></td><td>Receive a packet from a socket in passive mode.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Send a packet on a socket.</td></tr><tr><td valign="top"><a href="#setopts-2">setopts/2</a></td><td>Set one or more options for a socket.</td></tr><tr><td valign="top"><a href="#sockname-1">sockname/1</a></td><td>Get the local address and port of a socket.</td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="close-1"></a>
-###close/1##
+### close/1 ###
-<pre>close(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>) -> ok</pre>
+<pre><code>
+close(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>) -&gt; ok
+</code></pre>
+
<br></br>
Close a TCP socket.
-__See also:__ [ssl:close/1](ssl.md#close-1).<a name="connect-3"></a>
-
-###connect/3##
+__See also:__ [ssl:close/1](ssl.md#close-1).
+<a name="connect-3"></a>
+### connect/3 ###
`connect(Host, Port, Opts) -> any()`
+
+<a name="connect-4"></a>
+
+### connect/4 ###
+
+`connect(Host, Port, Opts, Timeout) -> any()`
+
+
<a name="controlling_process-2"></a>
-###controlling_process/2##
+### controlling_process/2 ###
+
+<pre><code>
+controlling_process(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Pid::pid()) -&gt; ok | {error, closed | not_owner | atom()}
+</code></pre>
-<pre>controlling_process(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Pid::pid()) -> ok | {error, closed | not_owner | atom()}</pre>
<br></br>
Assign a new controlling process _Pid_ to _Socket_.
-__See also:__ [ssl:controlling_process/2](ssl.md#controlling_process-2).<a name="peername-1"></a>
+__See also:__ [ssl:controlling_process/2](ssl.md#controlling_process-2).
+<a name="peername-1"></a>
-###peername/1##
+### peername/1 ###
-<pre>peername(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>) -> {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}</pre>
+<pre><code>
+peername(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>) -&gt; {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}
+</code></pre>
+
<br></br>
Return the address and port for the other end of a connection.
-__See also:__ [ssl:peername/1](ssl.md#peername-1).<a name="recv-2"></a>
-
-###recv/2##
+__See also:__ [ssl:peername/1](ssl.md#peername-1).
+<a name="recv-2"></a>
+### recv/2 ###
`recv(Socket, Length) -> any()`
+
<a name="recv-3"></a>
-###recv/3##
+### recv/3 ###
+
+<pre><code>
+recv(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Length::non_neg_integer(), Timeout::timeout()) -&gt; {ok, any()} | {error, closed | atom()}
+</code></pre>
-<pre>recv(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Length::non_neg_integer(), Timeout::timeout()) -> {ok, any()} | {error, closed | atom()}</pre>
<br></br>
Receive a packet from a socket in passive mode.
-__See also:__ [ssl:recv/3](ssl.md#recv-3).<a name="send-2"></a>
+__See also:__ [ssl:recv/3](ssl.md#recv-3).
+<a name="send-2"></a>
-###send/2##
+### send/2 ###
-<pre>send(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Packet::iolist()) -> ok | {error, atom()}</pre>
+<pre><code>
+send(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Packet::iolist()) -&gt; ok | {error, atom()}
+</code></pre>
+
<br></br>
Send a packet on a socket.
-__See also:__ [ssl:send/2](ssl.md#send-2).<a name="setopts-2"></a>
+__See also:__ [ssl:send/2](ssl.md#send-2).
+<a name="setopts-2"></a>
+
+### setopts/2 ###
-###setopts/2##
+<pre><code>
+setopts(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Opts::list()) -&gt; ok | {error, atom()}
+</code></pre>
-<pre>setopts(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>, Opts::list()) -> ok | {error, atom()}</pre>
<br></br>
Set one or more options for a socket.
-__See also:__ [ssl:setopts/2](ssl.md#setopts-2).<a name="sockname-1"></a>
+__See also:__ [ssl:setopts/2](ssl.md#setopts-2).
+<a name="sockname-1"></a>
+
+### sockname/1 ###
-###sockname/1##
+<pre><code>
+sockname(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>) -&gt; {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}
+</code></pre>
-<pre>sockname(Socket::<a href="ssl.md#type-sslsocket">ssl:sslsocket()</a>) -> {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}</pre>
<br></br>
Get the local address and port of a socket
-__See also:__ [ssl:sockname/1](ssl.md#sockname-1).
+__See also:__ [ssl:sockname/1](ssl.md#sockname-1).
View
18 doc/hackney_sup.md
@@ -1,33 +1,33 @@
-#Module hackney_sup#
+# Module hackney_sup #
* [Function Index](#index)
* [Function Details](#functions)
+__Behaviours:__ [`supervisor`](supervisor.md).
+<a name="index"></a>
-__Behaviours:__ [`supervisor`](supervisor.md).<a name="index"></a>
-
-##Function Index##
+## Function Index ##
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#init-1">init/1</a></td><td></td></tr><tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td></td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="init-1"></a>
-###init/1##
-
+### init/1 ###
`init(X1) -> any()`
-<a name="start_link-0"></a>
-###start_link/0##
+<a name="start_link-0"></a>
+### start_link/0 ###
`start_link() -> any()`
+
View
92 doc/hackney_tcp_transport.md
@@ -1,111 +1,145 @@
-#Module hackney_tcp_transport#
+# Module hackney_tcp_transport #
* [Function Index](#index)
* [Function Details](#functions)
<a name="index"></a>
-##Function Index##
+## Function Index ##
-<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#close-1">close/1</a></td><td>Close a TCP socket.</td></tr><tr><td valign="top"><a href="#connect-3">connect/3</a></td><td></td></tr><tr><td valign="top"><a href="#controlling_process-2">controlling_process/2</a></td><td>Assign a new controlling process <em>Pid</em> to <em>Socket</em>.</td></tr><tr><td valign="top"><a href="#peername-1">peername/1</a></td><td>Return the address and port for the other end of a connection.</td></tr><tr><td valign="top"><a href="#recv-2">recv/2</a></td><td></td></tr><tr><td valign="top"><a href="#recv-3">recv/3</a></td><td>Receive a packet from a socket in passive mode.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Send a packet on a socket.</td></tr><tr><td valign="top"><a href="#setopts-2">setopts/2</a></td><td>Set one or more options for a socket.</td></tr><tr><td valign="top"><a href="#sockname-1">sockname/1</a></td><td>Get the local address and port of a socket.</td></tr></table>
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#close-1">close/1</a></td><td>Close a TCP socket.</td></tr><tr><td valign="top"><a href="#connect-3">connect/3</a></td><td></td></tr><tr><td valign="top"><a href="#connect-4">connect/4</a></td><td></td></tr><tr><td valign="top"><a href="#controlling_process-2">controlling_process/2</a></td><td>Assign a new controlling process <em>Pid</em> to <em>Socket</em>.</td></tr><tr><td valign="top"><a href="#peername-1">peername/1</a></td><td>Return the address and port for the other end of a connection.</td></tr><tr><td valign="top"><a href="#recv-2">recv/2</a></td><td></td></tr><tr><td valign="top"><a href="#recv-3">recv/3</a></td><td>Receive a packet from a socket in passive mode.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Send a packet on a socket.</td></tr><tr><td valign="top"><a href="#setopts-2">setopts/2</a></td><td>Set one or more options for a socket.</td></tr><tr><td valign="top"><a href="#sockname-1">sockname/1</a></td><td>Get the local address and port of a socket.</td></tr></table>
<a name="functions"></a>
-##Function Details##
+## Function Details ##
<a name="close-1"></a>
-###close/1##
+### close/1 ###
-<pre>close(Socket::<a href="inet.md#type-socket">inet:socket()</a>) -> ok</pre>
+<pre><code>
+close(Socket::<a href="inet.md#type-socket">inet:socket()</a>) -&gt; ok
+</code></pre>
+
<br></br>
Close a TCP socket.
-__See also:__ [gen_tcp:close/1](gen_tcp.md#close-1).<a name="connect-3"></a>
-
-###connect/3##
+__See also:__ [gen_tcp:close/1](gen_tcp.md#close-1).
+<a name="connect-3"></a>
+### connect/3 ###
`connect(Host, Port, Opts) -> any()`
+
+<a name="connect-4"></a>
+
+### connect/4 ###
+
+`connect(Host, Port, Opts, Timeout) -> any()`
+
+
<a name="controlling_process-2"></a>
-###controlling_process/2##
+### controlling_process/2 ###
+
+<pre><code>
+controlling_process(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Pid::pid()) -&gt; ok | {error, closed | not_owner | atom()}
+</code></pre>
-<pre>controlling_process(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Pid::pid()) -> ok | {error, closed | not_owner | atom()}</pre>
<br></br>
Assign a new controlling process _Pid_ to _Socket_.
-__See also:__ [gen_tcp:controlling_process/2](gen_tcp.md#controlling_process-2).<a name="peername-1"></a>
+__See also:__ [gen_tcp:controlling_process/2](gen_tcp.md#controlling_process-2).
+<a name="peername-1"></a>
-###peername/1##
+### peername/1 ###
-<pre>peername(Socket::<a href="inet.md#type-socket">inet:socket()</a>) -> {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}</pre>
+<pre><code>
+peername(Socket::<a href="inet.md#type-socket">inet:socket()</a>) -&gt; {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}
+</code></pre>
+
<br></br>
Return the address and port for the other end of a connection.
-__See also:__ [inet:peername/1](inet.md#peername-1).<a name="recv-2"></a>
-
-###recv/2##
+__See also:__ [inet:peername/1](inet.md#peername-1).
+<a name="recv-2"></a>
+### recv/2 ###
`recv(Socket, Length) -> any()`
+
<a name="recv-3"></a>
-###recv/3##
+### recv/3 ###
+
+<pre><code>
+recv(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Length::non_neg_integer(), Timeout::timeout()) -&gt; {ok, any()} | {error, closed | atom()}
+</code></pre>
-<pre>recv(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Length::non_neg_integer(), Timeout::timeout()) -> {ok, any()} | {error, closed | atom()}</pre>
<br></br>
Receive a packet from a socket in passive mode.
-__See also:__ [gen_tcp:recv/3](gen_tcp.md#recv-3).<a name="send-2"></a>
+__See also:__ [gen_tcp:recv/3](gen_tcp.md#recv-3).
+<a name="send-2"></a>
-###send/2##
+### send/2 ###
-<pre>send(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Packet::iolist()) -> ok | {error, atom()}</pre>
+<pre><code>
+send(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Packet::iolist()) -&gt; ok | {error, atom()}
+</code></pre>
+
<br></br>
Send a packet on a socket.
-__See also:__ [gen_tcp:send/2](gen_tcp.md#send-2).<a name="setopts-2"></a>
+__See also:__ [gen_tcp:send/2](gen_tcp.md#send-2).
+<a name="setopts-2"></a>
+
+### setopts/2 ###
-###setopts/2##
+<pre><code>
+setopts(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Opts::list()) -&gt; ok | {error, atom()}
+</code></pre>
-<pre>setopts(Socket::<a href="inet.md#type-socket">inet:socket()</a>, Opts::list()) -> ok | {error, atom()}</pre>
<br></br>
Set one or more options for a socket.
-__See also:__ [inet:setopts/2](inet.md#setopts-2).<a name="sockname-1"></a>
+__See also:__ [inet:setopts/2](inet.md#setopts-2).
+<a name="sockname-1"></a>
+
+### sockname/1 ###
-###sockname/1##
+<pre><code>
+sockname(Socket::<a href="inet.md#type-socket">inet:socket()</a>) -&gt; {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}
+</code></pre>
-<pre>sockname(Socket::<a href="inet.md#type-socket">inet:socket()</a>) -> {ok, {<a href="inet.md#type-ip_address">inet:ip_address()</a>, <a href="inet.md#type-port_number">inet:port_number()</a>}} | {error, atom()}</pre>
<br></br>
Get the local address and port of a socket
-__See also:__ [inet:sockname/1](inet.md#sockname-1).
+__See also:__ [inet:sockname/1](inet.md#sockname-1).
View
4 doc/hackney_transform.md
@@ -1,6 +1,6 @@
-#Module hackney_transform#
+# Module hackney_transform #
* [Description](#description)
@@ -10,5 +10,5 @@ calls into hackney:request(Method, ...).
<a name="description"></a>
-##Description##
+## Description ##
View
63 doc/hackney_url.md
@@ -1,6 +1,6 @@
-#Module hackney_url#
+# Module hackney_url #
* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
@@ -10,84 +10,103 @@ module to manage urls.