Class: Webmachine::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/webmachine/response.rb

Overview

Represents an HTTP response from Webmachine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Creates a new Response object with the appropriate defaults.



28
29
30
31
32
33
# File 'lib/webmachine/response.rb', line 28

def initialize
  @headers = {}
  @trace = []
  self.code = 200
  self.redirect = false      
end

Instance Attribute Details

#bodyString, #each



11
12
13
# File 'lib/webmachine/response.rb', line 11

def body
  @body
end

#codeFixnum



8
9
10
# File 'lib/webmachine/response.rb', line 8

def code
  @code
end

#end_stateSymbol



21
22
23
# File 'lib/webmachine/response.rb', line 21

def end_state
  @end_state
end

#errorString



25
26
27
# File 'lib/webmachine/response.rb', line 25

def error
  @error
end

#headersHash (readonly)



5
6
7
# File 'lib/webmachine/response.rb', line 5

def headers
  @headers
end

#redirecttrue, false Also known as: is_redirect?



14
15
16
# File 'lib/webmachine/response.rb', line 14

def redirect
  @redirect
end

#traceArray (readonly)



17
18
19
# File 'lib/webmachine/response.rb', line 17

def trace
  @trace
end

Instance Method Details

#do_redirect(location = nil) ⇒ Object

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.



41
42
43
44
# File 'lib/webmachine/response.rb', line 41

def do_redirect(location=nil)
  headers['Location'] = location.to_s if location
  self.redirect = true
end