Class: Crystal::Response

Inherits:
Object show all
Defined in:
lib/crystal/http/support/rack/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

attr_accessor :error # for specs



6
7
8
# File 'lib/crystal/http/support/rack/response.rb', line 6

def initialize
  @status, @headers, @body = 200, {}, ""
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/crystal/http/support/rack/response.rb', line 3

def body
  @body
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/crystal/http/support/rack/response.rb', line 3

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/crystal/http/support/rack/response.rb', line 3

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
# File 'lib/crystal/http/support/rack/response.rb', line 29

def == other
  super(other) || to_a == other
end

#content_typeObject



15
# File 'lib/crystal/http/support/rack/response.rb', line 15

def content_type; headers["Content-Type"] end

#content_type=(type) ⇒ Object



14
# File 'lib/crystal/http/support/rack/response.rb', line 14

def content_type= type; headers["Content-Type"] = type end

#content_type?Boolean

Returns:

  • (Boolean)


16
# File 'lib/crystal/http/support/rack/response.rb', line 16

def content_type?; !!content_type end

#empty?Boolean Also known as: blank?

Returns:

  • (Boolean)


33
34
35
# File 'lib/crystal/http/support/rack/response.rb', line 33

def empty?
  body.empty?
end

#inspectObject



25
26
27
# File 'lib/crystal/http/support/rack/response.rb', line 25

def inspect
  to_a.inspect
end

#locationObject



18
# File 'lib/crystal/http/support/rack/response.rb', line 18

def location; headers['Location'] end

#location=(location) ⇒ Object



19
# File 'lib/crystal/http/support/rack/response.rb', line 19

def location= location; headers['Location'] = location end

#to_aObject



21
22
23
# File 'lib/crystal/http/support/rack/response.rb', line 21

def to_a
  [status, headers, body]
end

#write(str) ⇒ Object



10
11
12
# File 'lib/crystal/http/support/rack/response.rb', line 10

def write str
  body << str
end