class Webmachine::Response

Represents an HTTP response from Webmachine.

Attributes

body[RW]

@return [String, each] The response body

code[RW]

@return [Integer] The HTTP status code of the response

error[RW]

@return [String] The error message when responding with an error

code
headers[R]

@return [HeaderHash] Response headers that will be sent to the client

is_redirect?[RW]

@return [true,false] Whether the response is a redirect

redirect[RW]

@return [true,false] Whether the response is a redirect

trace[R]

@return [Array] the list of states that were traversed

Public Class Methods

new() click to toggle source

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

do_redirect(location = nil) click to toggle source

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
Also aliased as: redirect_to
redirect_to(location = nil)
Alias for: do_redirect