Description
Hackney should NOT attempt to encode provided URLs, at least not without being asked to. At this level the library should assume that the URL is already properly encoded. The reason for this is that attempting to mimic the "convenience" of browsers introduces all sorts of ambiguities. (That functionality could be exposed via utility functions for clients that need it.)
For just one example, from hackney_url:
%% special case, when a % is passed to the path, check if
%% it's a valid escape sequence. If the sequence is valid we
%% don't try to encode it and continue, else, we encode it.
%% the behaviour is similar to the one you find in chrome:
%% http://src.chromium.org/viewvc/chrome/trunk/src/url/url_canon_path.cc
Eh? So, it is possible that in a single URL some "%" characters will get encoded and some will not??? What if calling code depends on hackney encoding the URL, but then one day is handed an unencoded URL with the literal characters "%2A" for instance? So hackney will not encode the "%", and the URL will eventually be mangled to contain "*" where "%2A" was intended.
Also, in the attempt to clean up for poorly-coded clients, it encodes "*" as "%2a", which is unnecessary and actually breaks with some URLs on some servers (us.rd.yahoo.com use "*" to demarcate a URL to syndicated content, and does not accept "%2a").
An HTTP client library, in contrast to a browser, should do the minimal parsing to separate out the scheme, host, port, user & password then pass the entire raw path[?query][#fragment] through without mangling it.
(Likewise, it should not second-guess the client and try to encode the host.)