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)
@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
Splits the header into the credentials.
def credentials self.split(/\s+/, 2) end