Class: Refraction::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Refraction::Request
- Defined in:
- lib/refraction.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #default_port ⇒ Object
- #found!(options) ⇒ Object
- #host ⇒ Object
- #http_host ⇒ Object
- #location ⇒ Object
-
#method ⇒ Object
backward compatibility: support URI::HTTP component names.
- #path ⇒ Object
- #permanent!(options) ⇒ Object
-
#port ⇒ Object
changing the scheme or host means use default port instead of port in original request.
- #query ⇒ Object
- #query_string ⇒ Object
- #respond!(status, headers, content) ⇒ Object
-
#response ⇒ Object
response.
- #rewrite!(options) ⇒ Object
-
#scheme ⇒ Object
use original request’s values when not set explicitly.
-
#set(options) ⇒ Object
actions.
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/refraction.rb', line 7 def action @action end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/refraction.rb', line 7 def @message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/refraction.rb', line 7 def status @status end |
Instance Method Details
#default_port ⇒ Object
77 78 79 80 81 82 |
# File 'lib/refraction.rb', line 77 def default_port case scheme when "http" ; 80 when "https" ; 443 end end |
#found!(options) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/refraction.rb', line 40 def found!() @action = :found @status = 302 set() @message = "moved to #{@uri}" end |
#host ⇒ Object
68 |
# File 'lib/refraction.rb', line 68 def host; @re_host || super; end |
#http_host ⇒ Object
84 85 86 |
# File 'lib/refraction.rb', line 84 def http_host self.port ? "#{self.host}:#{self.port}" : self.host end |
#location ⇒ Object
62 63 64 |
# File 'lib/refraction.rb', line 62 def location @re_location || url end |
#method ⇒ Object
backward compatibility: support URI::HTTP component names
10 |
# File 'lib/refraction.rb', line 10 def method; request_method; end |
#path ⇒ Object
69 |
# File 'lib/refraction.rb', line 69 def path; @re_path || super; end |
#permanent!(options) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/refraction.rb', line 33 def permanent!() @action = :permanent @status = 301 set() @message = "moved to #{@uri}" end |
#port ⇒ Object
changing the scheme or host means use default port instead of port in original request
73 74 75 |
# File 'lib/refraction.rb', line 73 def port @re_port || ((@re_scheme || @re_host) && default_port) || super end |
#query ⇒ Object
11 |
# File 'lib/refraction.rb', line 11 def query; query_string; end |
#query_string ⇒ Object
70 |
# File 'lib/refraction.rb', line 70 def query_string; @re_query || super; end |
#respond!(status, headers, content) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/refraction.rb', line 47 def respond!(status, headers, content) @action = :respond @status = status @headers = headers @message = content end |
#response ⇒ Object
response
56 57 58 59 60 |
# File 'lib/refraction.rb', line 56 def response headers = @headers || { 'Location' => location, 'Content-Type' => 'text/plain' } headers['Content-Length'] = .length.to_s [status, headers, []] end |
#rewrite!(options) ⇒ Object
28 29 30 31 |
# File 'lib/refraction.rb', line 28 def rewrite!() @action = :rewrite set() end |
#scheme ⇒ Object
use original request’s values when not set explicitly
67 |
# File 'lib/refraction.rb', line 67 def scheme; @re_scheme || super; end |
#set(options) ⇒ Object
actions
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/refraction.rb', line 15 def set() if .is_a?(String) @re_location = else @re_scheme = [:protocol] if [:protocol] # :protocol is alias for :scheme @re_scheme = [:scheme] if [:scheme] @re_host = [:host] if [:host] @re_port = [:port] if [:port] @re_path = [:path] if [:path] @re_query = [:query] if [:query] end end |