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
- #found!(options) ⇒ Object
- #host ⇒ Object
- #host_with_port ⇒ 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.
6 7 8 |
# File 'lib/refraction.rb', line 6 def action @action end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/refraction.rb', line 6 def end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/refraction.rb', line 6 def status @status end |
Instance Method Details
#found!(options) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/refraction.rb', line 39 def found!() @action = :found @status = 302 set() = "moved to #{@uri}" end |
#host ⇒ Object
67 |
# File 'lib/refraction.rb', line 67 def host; @re_host || super; end |
#host_with_port ⇒ Object
76 77 78 |
# File 'lib/refraction.rb', line 76 def host_with_port port.nil? || port == DEFAULT_PORTS[scheme] ? host : "#{host}:#{port}" end |
#http_host ⇒ Object
80 81 82 |
# File 'lib/refraction.rb', line 80 def http_host port ? "#{host}:#{port}" : host end |
#location ⇒ Object
61 62 63 |
# File 'lib/refraction.rb', line 61 def location @re_location || url end |
#method ⇒ Object
backward compatibility: support URI::HTTP component names
9 |
# File 'lib/refraction.rb', line 9 def method; request_method; end |
#path ⇒ Object
68 |
# File 'lib/refraction.rb', line 68 def path; @re_path || super; end |
#permanent!(options) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/refraction.rb', line 32 def permanent!() @action = :permanent @status = 301 set() = "moved to #{@uri}" end |
#port ⇒ Object
changing the scheme or host means use default port instead of port in original request
72 73 74 |
# File 'lib/refraction.rb', line 72 def port @re_port || ((@re_scheme || @re_host) && DEFAULT_PORTS[scheme]) || super end |
#query ⇒ Object
10 |
# File 'lib/refraction.rb', line 10 def query; query_string; end |
#query_string ⇒ Object
69 |
# File 'lib/refraction.rb', line 69 def query_string; @re_query || super; end |
#respond!(status, headers, content) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/refraction.rb', line 46 def respond!(status, headers, content) @action = :respond @status = status @headers = headers = content end |
#response ⇒ Object
response
55 56 57 58 59 |
# File 'lib/refraction.rb', line 55 def response headers = @headers || { 'Location' => location, 'Content-Type' => 'text/plain' } headers['Content-Length'] = .length.to_s [status, headers, []] end |
#rewrite!(options) ⇒ Object
27 28 29 30 |
# File 'lib/refraction.rb', line 27 def rewrite!() @action = :rewrite set() end |
#scheme ⇒ Object
use original request’s values when not set explicitly
66 |
# File 'lib/refraction.rb', line 66 def scheme; @re_scheme || super; end |
#set(options) ⇒ Object
actions
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/refraction.rb', line 14 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 |