Class: Gem::WebauthnListener::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/webauthn_listener/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Response

Returns a new instance of Response.



34
35
36
37
38
# File 'lib/rubygems/webauthn_listener/response.rb', line 34

def initialize(host)
  @host = host

  build_http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



28
29
30
# File 'lib/rubygems/webauthn_listener/response.rb', line 28

def http_response
  @http_response
end

Class Method Details

.for(host) ⇒ Object



30
31
32
# File 'lib/rubygems/webauthn_listener/response.rb', line 30

def self.for(host)
  new(host)
end

Instance Method Details

#to_sObject



40
41
42
43
44
45
46
# File 'lib/rubygems/webauthn_listener/response.rb', line 40

def to_s
  status_line = "HTTP/#{@http_response.http_version} #{@http_response.code} #{@http_response.message}\r\n"
  headers = @http_response.to_hash.map {|header, value| "#{header}: #{value.join(", ")}\r\n" }.join + "\r\n"
  body = @http_response.body ? "#{@http_response.body}\n" : ""

  status_line + headers + body
end