RFC1738: Uniform Resource Locators (URL) says:
The user name (and password), if present, are followed by a
commercial at-sign "@". Within the user and password field, any ":",
"@", or "/" must be encoded.
URI library is for dealing with URIs, so, when you parse an url-encode username or password. you get it url-encoded. e.g;
> URI.parse('http://email%40server.com@localhost').user
=> "email%40server.com"
However, RFC2617: HTTP Authentication: Basic and Digest Access Authentication says:
To receive authorization, the client sends the userid and password,
separated by a single colon (":") character, within a base64 [7]
encoded string in the credentials.
This means that we have to decode user and password from the uri when building the Authorization header.