Class: Protocol::HTTP::Header::Authorization

Inherits:
String
  • Object
show all
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

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

#credentialsTuple(String, String)

Splits the header and

Returns:

  • (Tuple(String, String))


17
18
19
# File 'lib/protocol/http/header/authorization.rb', line 17

def credentials
	self.split(/\s+/, 2)
end