class Scorched::Response
Attributes
halted[RW]
Public Instance Methods
body=(value)
click to toggle source
Automatically wraps the assigned value in an array if it doesn’t respond to “each“. Also filters out non-true values and empty strings.
Calls superclass method
# File lib/scorched/response.rb, line 17 def body=(value) value = [] if !value || value == '' super(value.respond_to?(:each) ? value : [value.to_s]) end
finish(*args, &block)
click to toggle source
Override finish to avoid using BodyProxy
# File lib/scorched/response.rb, line 23 def finish(*args, &block) self['Content-Type'] ||= 'text/html;charset=utf-8' @block = block if block if [204, 205, 304].include?(status.to_i) header.delete "Content-Type" header.delete "Content-Length" close [status.to_i, header, []] else [status.to_i, header, body] end end
merge!(response)
click to toggle source
Merges another response object (or response array) into self in order to preserve references to this response object.
# File lib/scorched/response.rb, line 5 def merge!(response) return self if response == self if Rack::Response === response response = [response.status, response.header, response] end self.status, self.body = response[0], response[2] self.header.merge!(response[1]) self end