Class: Spider::Request
Direct Known Subclasses
Constant Summary collapse
- BUFSIZE =
1024*4
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#controller_path ⇒ Object
Returns the value of attribute controller_path.
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#env ⇒ Object
Returns the value of attribute env.
-
#format ⇒ Object
Returns the value of attribute format.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#misc ⇒ Object
Returns the value of attribute misc.
-
#params ⇒ Object
Returns the value of attribute params.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#request_time ⇒ Object
Returns the value of attribute request_time.
-
#server ⇒ Object
Returns the value of attribute server.
-
#session ⇒ Object
Returns the value of attribute session.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
- #body=(b) ⇒ Object
-
#initialize(env) ⇒ Request
constructor
A new instance of Request.
-
#path ⇒ Object
Original request path.
- #read_body ⇒ Object
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spiderfw/controller/request.rb', line 23 def initialize(env) Spider::Logger.debug("REQUEST:") Spider::Logger.debug(env) @env = env @locale = Locale.current[0] @misc = {} @params = {} @action = "" @session = {} end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def action @action end |
#controller_path ⇒ Object
Returns the value of attribute controller_path.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def controller_path @controller_path end |
#cookies ⇒ Object
Returns the value of attribute cookies.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def @cookies end |
#env ⇒ Object
Returns the value of attribute env.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def env @env end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def format @format end |
#locale ⇒ Object
Returns the value of attribute locale.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def locale @locale end |
#misc ⇒ Object
Returns the value of attribute misc.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def misc @misc end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def params @params end |
#protocol ⇒ Object
Returns the value of attribute protocol.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def protocol @protocol end |
#request_time ⇒ Object
Returns the value of attribute request_time.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def request_time @request_time end |
#server ⇒ Object
Returns the value of attribute server.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def server @server end |
#session ⇒ Object
Returns the value of attribute session.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def session @session end |
#user_id ⇒ Object
Returns the value of attribute user_id.
4 5 6 |
# File 'lib/spiderfw/controller/request.rb', line 4 def user_id @user_id end |
Class Method Details
.current ⇒ Object
10 11 12 |
# File 'lib/spiderfw/controller/request.rb', line 10 def self.current Thread.current[:spider_request] ||= {} end |
.current=(val) ⇒ Object
14 15 16 |
# File 'lib/spiderfw/controller/request.rb', line 14 def self.current=(val) Thread.current[:spider_request] = val end |
.reset_current ⇒ Object
18 19 20 |
# File 'lib/spiderfw/controller/request.rb', line 18 def self.reset_current Thread.current[:spider_request] = nil end |
Instance Method Details
#body ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/spiderfw/controller/request.rb', line 38 def body b = @body.is_a?(String) ? StringIO.new(@body) : @body return nil unless b if block_given? b.rewind while (buf = b.read(BUFSIZE)) yield buf end end return b end |
#body=(b) ⇒ Object
34 35 36 |
# File 'lib/spiderfw/controller/request.rb', line 34 def body=(b) @body = b end |
#path ⇒ Object
Original request path
61 62 63 |
# File 'lib/spiderfw/controller/request.rb', line 61 def path @action end |
#read_body ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/spiderfw/controller/request.rb', line 51 def read_body return @body if @body.is_a?(String) b = '' self.body do |buf| b += buf end @body = b end |