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