Sha256: 2f2d9b33b0b5aaafb60529814bb90bb9b19c0ea0cf38db368e2c8da889762da2

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 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 initialize(env)
            Spider::Logger.debug("REQUEST:")
            Spider::Logger.debug(env)
            @env = env
            @locale = Locale.current[0]
            @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?
                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

3 entries across 3 versions & 1 rubygems

Version Path
spiderfw-0.5.13 lib/spiderfw/controller/request.rb
spiderfw-0.5.12 lib/spiderfw/controller/request.rb
spiderfw-0.5.11 lib/spiderfw/controller/request.rb