Block all request methods in host blocker

This commit is contained in:
Florian Bruhin 2017-05-03 08:41:49 +02:00
parent 7c6981e512
commit a77cb44723
3 changed files with 3 additions and 4 deletions

View File

@ -52,6 +52,7 @@ Changed
closes the current tab.
- With Qt 5.9, `content -> cookies-store` can now be set on QtWebEngine without
a restart.
- The adblocker now also blocks non-GET requests (e.g. POST)
Fixed
~~~~~

View File

@ -57,8 +57,7 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
info: QWebEngineUrlRequestInfo &info
"""
# FIXME:qtwebengine only block ads for NavigationTypeOther?
if (bytes(info.requestMethod()) == b'GET' and
self._host_blocker.is_blocked(info.requestUrl())):
if self._host_blocker.is_blocked(info.requestUrl()):
log.webview.info("Request to {} blocked by host blocker.".format(
info.requestUrl().host()))
info.block(True)

View File

@ -416,8 +416,7 @@ class NetworkManager(QNetworkAccessManager):
req.setRawHeader(header, value)
host_blocker = objreg.get('host-blocker')
if (op == QNetworkAccessManager.GetOperation and
host_blocker.is_blocked(req.url())):
if host_blocker.is_blocked(req.url()):
log.webview.info("Request to {} blocked by host blocker.".format(
req.url().host()))
return networkreply.ErrorNetworkReply(