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



40
41
42
43
44
45
46
# File 'lib/protocol/http/header/authorization.rb', line 40

def self.basic(username, password)
	encoded = "#{username}:#{password}"
	
	self.new(
		"Basic #{Base64.strict_encode64(encoded)}"
	)
end

Instance Method Details

#credentialsTuple(String, String)

Splits the header and

Returns:

  • (Tuple(String, String))


36
37
38
# File 'lib/protocol/http/header/authorization.rb', line 36

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