diff --git a/NEWS.md b/NEWS.md index b63be676..f82e3a9c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,13 +1,38 @@ # NEWS +1.16.0 - 2020-05-25 +------------------- + + +- pool: cache connection IDs +- pool; make sure to reuse a connection if the options match the one given in the request. fix usage with proxy and ssl + connections +- url: handle fragment correctly, a fragment is parsed first to not be mistaken with an URL +- ssl: fix validation with Erlang 19 & Erlang 20 +- ssl: handle tlsv1.3 on Erlang OTP 23 +- ssl: increase validation depth to match openssl default +- ssl: optimiaz partial chain handling +- ssl: fix hostname checking and correctly handle SNI +- ssl: fix ciphers +- request: fix regression with fully fqdn +- ssl: fix usage with OTP 23 +- url: decode username/password for basic auth parameters +- request: do not normalize when converting relative redirect to absolute +- ssl: update to certifi 2.5.2 +- request: handle Connection: close response header for stteam +- http: handle leading new lines in HTTP messages +- http: handle trailers in persistent connection +- pool: update pool timeout docummentation +- url: fix urlencode + 1.15.2 - 2019-09-25 ------------------- - doc: fix tes run example in readme -- fix: hackney stream, send `hackney_response` before calling `handle_error` +- fix: hackney stream, send `hackney_response` before calling `handle_error` - fix: error remove ssl `honor_cipher_order` option - doc: document self-signed certificate usage -- bump `ssl_verify_fun` to 1.1.5 +- bump `ssl_verify_fun` to 1.1.5 - fix: don't use default pool if set to false - fix: `hackney_headers_new:store/3` fix value appending to a list - fix: miscellaeous specs diff --git a/README.md b/README.md index 0cf21c0d..94eea46e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Copyright (c) 2012-2020 Benoît Chesneau. -__Version:__ 1.15.2 +__Version:__ 1.16.0 # hackney @@ -365,8 +365,7 @@ Options = [{timeout, 150000}, {max_connections, 100}], ok = hackney_pool:start_pool(PoolName, Options), ``` -`timeout` is the connection idle timeout. Connection will be closed and removed from the pool after this. - +`timeout` is the time we keep the connection alive in the pool, `max_connections` is the number of connections maintained in the pool. Each connection in a pool is monitored and closed connections are removed automatically. @@ -580,6 +579,8 @@ $ kill `cat httpbin.pid` hackney_app hackney_bstr hackney_connect +hackney_connection +hackney_connections hackney_cookie hackney_date hackney_headers diff --git a/doc/README.md b/doc/README.md index 85ee356c..faa504e5 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2,9 +2,9 @@ # hackney - HTTP client library in Erlang # -Copyright (c) 2012-2019 Benoît Chesneau. +Copyright (c) 2012-2020 Benoît Chesneau. -__Version:__ 1.15.2 +__Version:__ 1.16.0 # hackney @@ -579,6 +579,8 @@ $ kill `cat httpbin.pid` hackney_app hackney_bstr hackney_connect +hackney_connection +hackney_connections hackney_cookie hackney_date hackney_headers diff --git a/doc/edoc-info b/doc/edoc-info index 3eff2cea..196f18c9 100644 --- a/doc/edoc-info +++ b/doc/edoc-info @@ -1,9 +1,9 @@ %% encoding: UTF-8 {application,hackney}. -{modules,[hackney,hackney_app,hackney_bstr,hackney_connect,hackney_cookie, - hackney_date,hackney_headers,hackney_headers_new,hackney_http, - hackney_http_connect,hackney_local_tcp,hackney_manager, - hackney_metrics,hackney_multipart,hackney_pool,hackney_pool_handler, - hackney_request,hackney_response,hackney_socks5,hackney_ssl, - hackney_stream,hackney_sup,hackney_tcp,hackney_trace,hackney_url, - hackney_util]}. +{modules,[hackney,hackney_app,hackney_bstr,hackney_connect,hackney_connection, + hackney_connections,hackney_cookie,hackney_date,hackney_headers, + hackney_headers_new,hackney_http,hackney_http_connect, + hackney_local_tcp,hackney_manager,hackney_metrics,hackney_multipart, + hackney_pool,hackney_pool_handler,hackney_request,hackney_response, + hackney_socks5,hackney_ssl,hackney_stream,hackney_sup,hackney_tcp, + hackney_trace,hackney_url,hackney_util]}. diff --git a/doc/hackney_connect.md b/doc/hackney_connect.md index e49e94eb..965fd93e 100644 --- a/doc/hackney_connect.md +++ b/doc/hackney_connect.md @@ -9,7 +9,7 @@ ## Function Index ## -
check_or_close/1
close/1close the client.
connect/3
connect/4
connect/5
create_connection/4create a connection and return a client state.
create_connection/5
is_pool/1get current pool pid or name used by a client if needed.
maybe_connect/1connect a socket and create a client state.
partial_chain/1
peername/1get the address and port for the other end of current connection in the client.
reconnect/4
set_sockopts/2add set sockets options in the client.
sockname/1the local address and port of current socket in the client.
ssl_opts/2
+
check_or_close/1
close/1close the client.
connect/3
connect/4
connect/5
create_connection/4create a connection and return a client state.
create_connection/5
is_pool/1get current pool pid or name used by a client if needed.
maybe_connect/1connect a socket and create a client state.
peername/1get the address and port for the other end of current connection in the client.
reconnect/4
set_sockopts/2add set sockets options in the client.
sockname/1the local address and port of current socket in the client.
@@ -78,12 +78,6 @@ get current pool pid or name used by a client if needed connect a socket and create a client state. - - -### partial_chain/1 ### - -`partial_chain(Certs) -> any()` - ### peername/1 ### @@ -114,9 +108,3 @@ add set sockets options in the client the local address and port of current socket in the client - - -### ssl_opts/2 ### - -`ssl_opts(Host, Options) -> any()` - diff --git a/doc/hackney_connection.md b/doc/hackney_connection.md new file mode 100644 index 00000000..3487d3c0 --- /dev/null +++ b/doc/hackney_connection.md @@ -0,0 +1,78 @@ + + +# Module hackney_connection # +* [Function Index](#index) +* [Function Details](#functions) + + + +## Function Index ## + + +
close/2
connect/3
connect_options/3
controlling_process/3
get_property/2
is_ssl/1
new/1
setopts/3
ssl_opts/2
sync_socket/2
+ + + + +## Function Details ## + + + +### close/2 ### + +`close(Connection, Socket) -> any()` + + + +### connect/3 ### + +`connect(Connection, ConnectOptions, Timeout) -> any()` + + + +### connect_options/3 ### + +`connect_options(Transport, Host, ClientOptions) -> any()` + + + +### controlling_process/3 ### + +`controlling_process(Connection, Socket, Owner) -> any()` + + + +### get_property/2 ### + +`get_property(X1, Connection) -> any()` + + + +### is_ssl/1 ### + +`is_ssl(Connection) -> any()` + + + +### new/1 ### + +`new(Client) -> any()` + + + +### setopts/3 ### + +`setopts(Connection, Socket, Opts) -> any()` + + + +### ssl_opts/2 ### + +`ssl_opts(Host, Options) -> any()` + + + +### sync_socket/2 ### + +`sync_socket(Connection, Socket) -> any()` + diff --git a/doc/hackney_connections.md b/doc/hackney_connections.md new file mode 100644 index 00000000..09506531 --- /dev/null +++ b/doc/hackney_connections.md @@ -0,0 +1,86 @@ + + +# Module hackney_connections # +* [Function Index](#index) +* [Function Details](#functions) + +__Behaviours:__ [`gen_server`](gen_server.md). + + + +## Function Index ## + + +
code_change/3
delete/1
get_num_entries/0
handle_call/3
handle_cast/2
handle_info/2
init/1
insert/2
lookup/1
start_link/0
terminate/2
+ + + + +## Function Details ## + + + +### code_change/3 ### + +`code_change(OldVsn, State, Extra) -> any()` + + + +### delete/1 ### + +`delete(Key) -> any()` + + + +### get_num_entries/0 ### + +`get_num_entries() -> any()` + + + +### handle_call/3 ### + +`handle_call(Msg, From, State) -> any()` + + + +### handle_cast/2 ### + +`handle_cast(Msg, State) -> any()` + + + +### handle_info/2 ### + +`handle_info(Info, State) -> any()` + + + +### init/1 ### + +`init(X1) -> any()` + + + +### insert/2 ### + +`insert(Key, Id) -> any()` + + + +### lookup/1 ### + +`lookup(Key) -> any()` + + + +### start_link/0 ### + +`start_link() -> any()` + + + +### terminate/2 ### + +`terminate(Reason, State) -> any()` + diff --git a/doc/hackney_pool.md b/doc/hackney_pool.md index df40657e..850c8b00 100644 --- a/doc/hackney_pool.md +++ b/doc/hackney_pool.md @@ -34,7 +34,7 @@ release a socket in the pool ### checkout/4 ### -`checkout(Host0, Port, Transport, Client) -> any()` +`checkout(Host, Port, Transport, Client) -> any()` fetch a socket from the pool diff --git a/doc/hackney_ssl.md b/doc/hackney_ssl.md index 7a46cca9..36edc67f 100644 --- a/doc/hackney_ssl.md +++ b/doc/hackney_ssl.md @@ -9,13 +9,31 @@ ## Function Index ## -
close/1Close a TCP socket.
connect/3
connect/4
controlling_process/2Assign a new controlling process Pid to Socket.
messages/1Atoms used to identify messages in {active, once | true} mode.
peername/1Return the address and port for the other end of a connection.
recv/2
recv/3Receive a packet from a socket in passive mode.
send/2Send a packet on a socket.
setopts/2Set one or more options for a socket.
shutdown/2Immediately close a socket in one or two directions.
sockname/1Get the local address and port of a socket.
+
check_hostname_opts/1
cipher_opts/0
cipher_opts/0
close/1Close a TCP socket.
connect/3
connect/4
controlling_process/2Assign a new controlling process Pid to Socket.
messages/1Atoms used to identify messages in {active, once | true} mode.
peername/1Return the address and port for the other end of a connection.
recv/2
recv/3Receive a packet from a socket in passive mode.
send/2Send a packet on a socket.
setopts/2Set one or more options for a socket.
shutdown/2Immediately close a socket in one or two directions.
sockname/1Get the local address and port of a socket.
## Function Details ## + + +### check_hostname_opts/1 ### + +`check_hostname_opts(Host0) -> any()` + + + +### cipher_opts/0 ### + +`cipher_opts() -> any()` + + + +### cipher_opts/0 ### + +`cipher_opts() -> any()` + ### close/1 ### diff --git a/doc/hackney_url.md b/doc/hackney_url.md index 8234e69d..9a153a1e 100644 --- a/doc/hackney_url.md +++ b/doc/hackney_url.md @@ -38,7 +38,7 @@ qs_vals() = [{binary(), binary() | true}]
fix_path/1
idnconvert_hostname/1
make_url/3Construct an URL from a base URL, a path and a list of -properties to give to the URL.
normalize/1Normalizes the encoding of an URL.
normalize/2Normalizes the encoding of an URL.
parse_qs/1
parse_url/1Parse an URL and return a #hackney_url record.
pathencode/1Encode an URL path.
qs/1Encode query properties to binary.
qs/2Encode query properties to binary.
transport_scheme/1
unparse_url/1
urldecode/1Decode an URL encoded binary.
urldecode/2Decode an URL encoded binary.
urlencode/1URL encode a string binary.
urlencode/2URL encode a string binary.
+properties to give to the URL.normalize/1Normalizes the encoding of an URL.normalize/2Normalizes the encoding of an URL.parse_qs/1parse_url/1Parse an URL and return a #hackney_url record.pathencode/1Encode an URL path.property/2qs/1Encode query properties to binary.qs/2Encode query properties to binary.transport_scheme/1unparse_url/1urldecode/1Decode an URL encoded binary.urldecode/2Decode an URL encoded binary.urlencode/1URL encode a string binary.urlencode/2URL encode a string binary. @@ -119,7 +119,7 @@ Parse an URL and return a #hackney_url record. ### pathencode/1 ###

-pathencode(Bin::binary()) -> binary()
+pathencode(Path::binary() | list()) -> binary()
 

@@ -127,6 +127,12 @@ Equivalent to [`pathencode(Bin, [])`](#pathencode-2). Encode an URL path. + + +### property/2 ### + +`property(X1, URL) -> any()` + ### qs/1 ### diff --git a/doc/overview.edoc b/doc/overview.edoc index a8b7cd5e..de8980af 100644 --- a/doc/overview.edoc +++ b/doc/overview.edoc @@ -16,8 +16,8 @@ %%============================================================================== -@copyright 2012-2019 Benoît Chesneau. -@version 1.15.2 +@copyright 2012-2020 Benoît Chesneau. +@version 1.16.0 @title hackney - HTTP client library in Erlang @doc diff --git a/src/hackney.app.src b/src/hackney.app.src index 1dd416b9..72cff73a 100644 --- a/src/hackney.app.src +++ b/src/hackney.app.src @@ -4,7 +4,7 @@ {application, hackney, [ {description, "simple HTTP client"}, - {vsn, "1.15.2"}, + {vsn, "1.16.0"}, {registered, [hackney_pool]}, {applications, [kernel, stdlib, diff --git a/src/hackney_connection.erl b/src/hackney_connection.erl index d8d308ed..acb8ff17 100644 --- a/src/hackney_connection.erl +++ b/src/hackney_connection.erl @@ -1,3 +1,8 @@ +%%% -*- erlang -*- +%%% +%%% This file is part of hackney released under the Apache 2 license. +%%% See the NOTICE for more information + -module(hackney_connection). diff --git a/src/hackney_connections.erl b/src/hackney_connections.erl index d241e354..20867436 100644 --- a/src/hackney_connections.erl +++ b/src/hackney_connections.erl @@ -1,3 +1,8 @@ +%%% -*- erlang -*- +%%% +%%% This file is part of hackney released under the Apache 2 license. +%%% See the NOTICE for more information + -module(hackney_connections). -behaviour(gen_server).