class Webmachine::Response
Represents an HTTP response from Webmachine
.
Attributes
@return [String, each] The response body
@return [Integer] The HTTP status code of the response
@return [String] The error message when responding with an error
code
@return [HeaderHash] Response
headers that will be sent to the client
@return [true,false] Whether the response is a redirect
@return [true,false] Whether the response is a redirect
@return [Array] the list of states that were traversed
Public Class Methods
Creates a new Response
object with the appropriate defaults.
# File lib/webmachine/response.rb, line 24 def initialize @headers = HeaderHash.new @trace = [] self.code = 200 self.redirect = false end
Public Instance Methods
Indicate that the response should be a redirect. This is only used when processing a POST request in {Resource::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
# File lib/webmachine/response.rb, line 38 def do_redirect(location = nil) headers['Location'] = location.to_s if location self.redirect = true end