app.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:opendxl-maxmind-service-python 作者: opendxl 项目源码 文件源码
def _is_update_needed(self):
        """
        Determines if an update for the database is necessary

        :return: Whether or not the database should be updated
        """

        # Retrieve the headers of the response to compare the MD5 checksums of the file
        headers_response = requests.head(self.MAXMIND_FREE_DB_URL)
        logger.debug(headers_response.headers)
        headers_response.raise_for_status()
        response_checksum = headers_response.headers.get('X-Database-MD5')
        logger.info("Database MD5 received in response headers: " + str(response_checksum))
        # Compare the current file checksum to the one received from MaxMind
        if response_checksum is not None and response_checksum == self._database_checksum:
            return False
        self._response_checksum = response_checksum
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号