Class: HttpResponseImpl

Inherits:
Object
  • Object
show all
Defined in:
lib/resurfaceio/http_response_impl.rb

Overview

© 2016-2021 Resurface Labs Inc.

Direct Known Subclasses

Resurfaceio::HttpResponseImpl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHttpResponseImpl

Returns a new instance of HttpResponseImpl.



6
7
8
9
# File 'lib/resurfaceio/http_response_impl.rb', line 6

def initialize
  @headers = Hash.new
  @raw_body = nil
end

Instance Attribute Details

#raw_bodyObject

Returns the value of attribute raw_body.



38
39
40
# File 'lib/resurfaceio/http_response_impl.rb', line 38

def raw_body
  @raw_body
end

#statusObject

Returns the value of attribute status.



39
40
41
# File 'lib/resurfaceio/http_response_impl.rb', line 39

def status
  @status
end

Instance Method Details

#add_header(key, value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/resurfaceio/http_response_impl.rb', line 11

def add_header(key, value)
  unless value.nil?
    existing = @headers[key]
    if existing.nil?
      @headers[key] = value
    else
      @headers[key] = "#{existing}, #{value}"
    end
  end
end

#bodyObject



22
23
24
# File 'lib/resurfaceio/http_response_impl.rb', line 22

def body
  @raw_body ? [@raw_body] : nil
end

#content_typeObject



26
27
28
# File 'lib/resurfaceio/http_response_impl.rb', line 26

def content_type
  @headers['Content-Type']
end

#content_type=(content_type) ⇒ Object



30
31
32
# File 'lib/resurfaceio/http_response_impl.rb', line 30

def content_type=(content_type)
  @headers['Content-Type'] = content_type
end

#headersObject



34
35
36
# File 'lib/resurfaceio/http_response_impl.rb', line 34

def headers
  @headers
end