From 97578df7a5d6d482f35b3fe0cd684490bb069ca6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 22 Apr 2014 16:09:41 +0200 Subject: [PATCH] Use QHostInfo instead of socket to resolve --- qutebrowser/utils/url.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/qutebrowser/utils/url.py b/qutebrowser/utils/url.py index d887769bb..88482c3fc 100644 --- a/qutebrowser/utils/url.py +++ b/qutebrowser/utils/url.py @@ -18,11 +18,11 @@ """Utils regarding URL handling.""" import re -import socket import logging import urllib.parse from PyQt5.QtCore import QUrl +from PyQt5.QtNetwork import QHostInfo import qutebrowser.config.config as config @@ -84,18 +84,12 @@ def _is_url_dns(url): Return: True if the url really is an URL, False otherwise. """ - # FIXME If we use Qt's methods to resolve URLs, we could benefit from the - # build-in cache and wouldn't have to resolve again. host = url.host() logging.debug("DNS request for {}".format(host)) if not host: return False - try: - socket.gethostbyname(host) - except socket.gaierror: - return False - else: - return True + info = QHostInfo.fromName(host) + return not info.error() def qurl(url):