Class: Debugbar::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/debugbar/http/http.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ HttpResponse

Returns a new instance of HttpResponse.



28
29
30
31
32
# File 'lib/debugbar/http/http.rb', line 28

def initialize(status, headers, body)
  @status = status
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



26
27
28
# File 'lib/debugbar/http/http.rb', line 26

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



26
27
28
# File 'lib/debugbar/http/http.rb', line 26

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



26
27
28
# File 'lib/debugbar/http/http.rb', line 26

def status
  @status
end

Class Method Details

.from_rack(rack_res) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/debugbar/http/http.rb', line 34

def self.from_rack(rack_res)
  return nil if rack_res.nil?

  headers = rack_res.headers.to_h.transform_keys { |s| s.split('-').map(&:capitalize).join('-') }

  new(rack_res.status, headers, rack_res.body)
end

Instance Method Details

#to_hObject



42
43
44
# File 'lib/debugbar/http/http.rb', line 42

def to_h
  { status:, headers:, body: }
end