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

- (Response) initialize

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

- (String, #each) body



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

def body
  @body
end

- (Fixnum) code



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

def code
  @code
end

- (Symbol) end_state



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

def end_state
  @end_state
end

- (String) error



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

def error
  @error
end

- (Hash) headers (readonly)



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

def headers
  @headers
end

- (true, false) redirect Also known as: is_redirect?



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

def redirect
  @redirect
end

- (Array) trace (readonly)



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

def trace
  @trace
end

Instance Method Details

- (Object) do_redirect(location = nil)

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