Class: Gem::GemcutterUtilities::WebauthnListener::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/gemcutter_utilities/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.



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

def initialize(host)
  @host = host

  build_http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



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

def http_response
  @http_response
end

Class Method Details

.for(host) ⇒ Object



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

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

Instance Method Details

#to_sObject



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

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