Sha256: 883709e9fe5dd002f12ff824292248c3752145b1641dd9293138c12036d4a815
Contents?: true
Size: 1.5 KB
Versions: 24
Compression:
Stored size: 1.5 KB
Contents
module Webmachine # Represents an HTTP response from Webmachine. class Response # @return [Hash] Response headers that will be sent to the client attr_reader :headers # @return [Fixnum] The HTTP status code of the response attr_accessor :code # @return [String, #each] The response body attr_accessor :body # @return [true,false] Whether the response is a redirect attr_accessor :redirect # @return [Array] the list of states that were traversed attr_reader :trace # @return [Symbol] When an error has occurred, the last state the # FSM was in attr_accessor :end_state # @return [String] The error message when responding with an error # code attr_accessor :error # Creates a new Response object with the appropriate defaults. def initialize @headers = {} @trace = [] self.code = 200 self.redirect = false end # Indicate that the response should be a redirect. This is only # used when processing a POST request in {Callbacks#process_post} # to indicate that the client should request another resource # using GET. Either pass the URI of the target resource, or # manually set the Location header using {#headers}. # @param [String, URI] location the target of the redirection def do_redirect(location=nil) headers['Location'] = location.to_s if location self.redirect = true end alias :is_redirect? :redirect alias :redirect_to :do_redirect end end
Version data entries
24 entries across 5 versions & 1 rubygems