Sha256: d7f5f195b7c4c610f36dc7b4b3a84343abd8eacd6ad40a8223558499c7bf36c9

Contents?: true

Size: 1.54 KB

Versions: 30

Compression:

Stored size: 1.54 KB

Contents

require 'spiderfw/controller/cookies'

module Spider
    
    class Response
        attr_reader :status
        attr_accessor :headers, :server_output, :cookies
        
        def initialize()
            @headers = {}
            @cookies = Cookies.new
        end
        
        def body=(io)
            @server_output.set_body_io(io)
        end
        
        def register(key, val)
            instance_variable_set("@#{key}", val)
            self.class.send(:attr_accessor, key) # FIXME: threadsafety
        end
        
        def no_cookies
            @no_cookies = true
        end
        
        def prepare_headers
            unless @no_cookies
                @headers['Set-Cookie'] ||= []
                @cookies.each do |k, v|
                    h = "#{k}=#{v}"
                    h += '; expires='+v.expires.strftime("%a, %b %d %Y %H:%M:%S %Z") if (v.expires.respond_to?(:strftime))
                    h += "; path=#{v.path}" if (v.path)
                    h += "; domain=#{v.domain}" if (v.domain)
                    h += "; secure" if (v.secure)
                    @headers['Set-Cookie'] << h
                end
            end
            Spider::Logger.debug("HEADERS:")
            Spider::Logger.debug(@headers)
        end
        
        def status=(code)
            @status = code
            # if (Spider::HTTP.status_messages[code])
            #     @status = code.to_s+' '+Spider::HTTP.status_messages[code]
            # else
            #     @status = code
            # end
        end

        
    end
    
    
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
spiderfw-0.6.23 lib/spiderfw/controller/response.rb
spiderfw-0.6.22 lib/spiderfw/controller/response.rb
spiderfw-0.6.21 lib/spiderfw/controller/response.rb
spiderfw-0.6.20 lib/spiderfw/controller/response.rb
spiderfw-0.6.19 lib/spiderfw/controller/response.rb
spiderfw-0.6.18 lib/spiderfw/controller/response.rb
spiderfw-0.6.17 lib/spiderfw/controller/response.rb
spiderfw-0.6.16 lib/spiderfw/controller/response.rb
spiderfw-0.6.15 lib/spiderfw/controller/response.rb
spiderfw-0.6.14 lib/spiderfw/controller/response.rb
spiderfw-0.6.13 lib/spiderfw/controller/response.rb
spiderfw-0.6.12 lib/spiderfw/controller/response.rb
spiderfw-0.6.11 lib/spiderfw/controller/response.rb
spiderfw-0.6.10 lib/spiderfw/controller/response.rb
spiderfw-0.6.9 lib/spiderfw/controller/response.rb
spiderfw-0.6.8 lib/spiderfw/controller/response.rb
spiderfw-0.6.7 lib/spiderfw/controller/response.rb
spiderfw-0.6.6 lib/spiderfw/controller/response.rb
spiderfw-0.6.5 lib/spiderfw/controller/response.rb
spiderfw-0.6.4 lib/spiderfw/controller/response.rb