# File lib/rbot/core/utils/httputil.rb, line 203 def self.maybe_new(resp) debug "maybe new #{resp}" return nil if resp.no_cache return nil unless Net::HTTPOK === resp || Net::HTTPMovedPermanently === resp || Net::HTTPFound === resp || Net::HTTPPartialContent === resp cc = resp['cache-control'] return nil if cc && (cc =~ /no-cache/) date = Time.now if d = resp['date'] date = Time.httpdate(d) end return nil if resp['expires'] && (Time.httpdate(resp['expires']) < date) debug "creating cache obj" self.new(resp) end
# File lib/rbot/core/utils/httputil.rb, line 233 def expired? debug "checking expired?" if cc = self.response['cache-control'] && cc =~ /must-revalidate/ return true end return self.expires < Time.now end
# File lib/rbot/core/utils/httputil.rb, line 252 def revalidate(resp = self.response) @count = 0 self.use self.date = resp.key?('date') ? Time.httpdate(resp['date']) : Time.now cc = resp['cache-control'] if cc && (cc =~ /max-age=(\d+)/) self.expires = self.date + $1.to_i elsif resp.key?('expires') self.expires = Time.httpdate(resp['expires']) elsif lm = resp['last-modified'] delta = self.date - Time.httpdate(lm) delta = 10 if delta <= 0 delta /= 5 self.expires = self.date + delta else self.expires = self.date + 300 end # self.expires = Time.now + 10 # DEBUG debug "expires on #{self.expires}" return true end
Generated with the Darkfish Rdoc Generator 2.