Sha256: 5edb1b57445665bed433fecf7a72f095f6ccb56ea65785f416f9705d8f0fa51d

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 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 prepare_headers
            @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
            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

13 entries across 13 versions & 1 rubygems

Version Path
spiderfw-0.5.13 lib/spiderfw/controller/response.rb
spiderfw-0.5.12 lib/spiderfw/controller/response.rb
spiderfw-0.5.11 lib/spiderfw/controller/response.rb
spiderfw-0.5.10 lib/spiderfw/controller/response.rb
spiderfw-0.5.9 lib/spiderfw/controller/response.rb
spiderfw-0.5.7 lib/spiderfw/controller/response.rb
spiderfw-0.5.6 lib/spiderfw/controller/response.rb
spiderfw-0.5.5 lib/spiderfw/controller/response.rb
spiderfw-0.5.4 lib/spiderfw/controller/response.rb
spiderfw-0.5.3 lib/spiderfw/controller/response.rb
spiderfw-0.5.2 lib/spiderfw/controller/response.rb
spiderfw-0.5.1 lib/spiderfw/controller/response.rb
spiderfw-0.5 lib/spiderfw/controller/response.rb