class Protocol::HTTP::Header::Authorization

TODO Support other authorization mechanisms, e.g. bearer token.
~~~
headers.add(‘authorization’, Authorization.basic(“my_username”, “my_password”))
~~~ ruby
Used for basic authorization.

def self.basic(username, password)

@returns [Authorization] The basic authorization header.
@parameter password [String] The password.
@parameter username [String] The username.

Generate a new basic authorization header, encoding the given username and password.
def self.basic(username, password)
	strict_base64_encoded = ["#{username}:#{password}"].pack("m0")
	
	self.new(
		"Basic #{strict_base64_encoded}"
	)
end

def credentials

@returns [Tuple(String, String)] The username and password.

Splits the header into the credentials.
def credentials
	self.split(/\s+/, 2)
end