code: def is_internal_request(self, domain, referer):
          
          # Different subdomains are treated as different domains.
          return bool(re.match("^https?://%s/" % re.escape(domain), referer))
docs: Returns True if referring URL is the same domain as current request.