Class: Protocol::HTTP::Header::Authorization
- Inherits:
-
String
- Object
- String
- Protocol::HTTP::Header::Authorization
- Defined in:
- lib/protocol/http/header/authorization.rb
Overview
Used for basic authorization.
~~~ ruby headers.add(‘authorization’, Authorization.basic(“my_username”, “my_password”)) ~~~
Class Method Summary collapse
Instance Method Summary collapse
-
#credentials ⇒ Tuple(String, String)
Splits the header and.
Class Method Details
.basic(username, password) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/protocol/http/header/authorization.rb', line 21 def self.basic(username, password) strict_base64_encoded = ["#{username}:#{password}"].pack('m0') self.new( "Basic #{strict_base64_encoded}" ) end |
Instance Method Details
#credentials ⇒ Tuple(String, String)
Splits the header and
17 18 19 |
# File 'lib/protocol/http/header/authorization.rb', line 17 def credentials self.split(/\s+/, 2) end |