class Cuba::Response
Constants
- LOCATION
Attributes
body[R]
headers[R]
status[RW]
Public Class Methods
new(headers = {})
click to toggle source
# File lib/cuba.rb, line 18 def initialize(headers = {}) @status = nil @headers = headers @body = [] @length = 0 end
Public Instance Methods
[](key)
click to toggle source
# File lib/cuba.rb, line 25 def [](key) @headers[key] end
[]=(key, value)
click to toggle source
# File lib/cuba.rb, line 29 def []=(key, value) @headers[key] = value end
finish()
click to toggle source
# File lib/cuba.rb, line 46 def finish [@status, @headers, @body] end
redirect(path, status = 302)
click to toggle source
# File lib/cuba.rb, line 41 def redirect(path, status = 302) @headers[LOCATION] = path @status = status end
write(str)
click to toggle source
# File lib/cuba.rb, line 33 def write(str) s = str.to_s @length += s.bytesize @headers[Rack::CONTENT_LENGTH] = @length.to_s @body << s end