Jason R. Coombs  committed 6f705f3

Inverted boolean logic when checking max-age

  • Participants
  • Parent commits a60d7af
  • Branches default

Comments (0)

Files changed (1)

File jaraco/net/http/

 		cc = CacheHandler._parse_cache_control(self.headers)
 		if 'no-cache' in cc:
 			return False
-		if not self.within_max_age(cc):
+		if self.exceeds_max_age(cc):
 			return False
 		if 'expires' in cc:
 		respect to the request headers.
 		cc = CacheHandler._parse_cache_control(req_headers)
-		return self.fresh() and self.within_max_age(cc)
+		return self.fresh() and not self.exceeds_max_age(cc)
-	def within_max_age(self, cache_control):
+	def exceeds_max_age(self, cache_control):
 		if not 'date' in self.headers:
-			return False
+			return True
 		if 'max-age' not in cache_control:
-			return False
+			return True
 		# user-agent might have a 'min-fresh' directive indicating the
 		#  client will only accept a cached request if it will still be
 		#  fresh min-fresh seconds from now.
 			max_age = datetime.timedelta(
 			if self.age + min_fresh > max_age:
-				return False
+				return True
 		except ValueError:
-		return True
+		return False
 	def update_headers(self, new_headers):
 		for header in get_endpoint_headers(new_headers):