diff options
author | Florian Bruhin <me@the-compiler.org> | 2018-12-10 14:39:07 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2018-12-10 15:03:09 +0100 |
commit | 7ad7623d7338d20c339684117487a98aac589ac8 (patch) | |
tree | b1ba8935995b4843d95159d7a4b7682e94b1f75a /qutebrowser/api | |
parent | 3d6f604739f65bda407c4608ae203e0788c531f6 (diff) | |
download | qutebrowser-7ad7623d7338d20c339684117487a98aac589ac8.tar.gz qutebrowser-7ad7623d7338d20c339684117487a98aac589ac8.zip |
Add request filter API for host blocking
Closes https://github.com/qutebrowser/qutebrowser-extensions/issues/8
Diffstat (limited to 'qutebrowser/api')
-rw-r--r-- | qutebrowser/api/requests.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/qutebrowser/api/requests.py b/qutebrowser/api/requests.py new file mode 100644 index 000000000..990faec88 --- /dev/null +++ b/qutebrowser/api/requests.py @@ -0,0 +1,37 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. + +"""APIs related to intercepting/blocking requests.""" + +import typing + +import attr +from PyQt5.QtCore import QUrl + +from qutebrowser.extensions import requests +# pylint: disable=unused-import +from qutebrowser.extensions.requests import Request + + +def register_filter(reqfilter: requests.RequestFilterType) -> None: + """Register a request filter. + + Whenever a request happens, the filter gets called with a Request object. + """ + requests.register_filter(reqfilter) |