Sha256: f0435c706befa92e7a33e8e0c2d7d49aea11b7ebd1cac24d878060e1f3a23b4c
Contents?: true
Size: 1.49 KB
Versions: 20
Compression:
Stored size: 1.49 KB
Contents
module Spider class Request attr_accessor :action, :params, :cookies, :env, :protocol, :format, :session, :user_id, :server, :request_time, :controller_path, :locale, :misc BUFSIZE = 1024*4 def self.current Thread.current[:spider_request] ||= {} end def self.current=(val) Thread.current[:spider_request] = val end def self.reset_current Thread.current[:spider_request] = nil end def initialize(env) @env = env @locale = Spider.locale @misc = {} @params = {} @action = "" @session = {} end def body=(b) @body = b end 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 def read_body return @body if @body.is_a?(String) b = '' self.body do |buf| b += buf end @body = b end # Original request path def path @action end end end
Version data entries
20 entries across 20 versions & 1 rubygems