Add do-not-track and accept-language headers
This commit is contained in:
parent
31ab264fe8
commit
8556d06ae7
@ -56,6 +56,7 @@ FIRST_COMMENT = """
|
|||||||
SECTION_DESC = {
|
SECTION_DESC = {
|
||||||
'general': "General/misc. options",
|
'general': "General/misc. options",
|
||||||
'input': "Options related to input modes.",
|
'input': "Options related to input modes.",
|
||||||
|
'network': "Settings related to the network.",
|
||||||
'completion': "Options related to completion and command history .",
|
'completion': "Options related to completion and command history .",
|
||||||
'tabbar': "Configuration of the tab bar.",
|
'tabbar': "Configuration of the tab bar.",
|
||||||
'webkit': "Webkit settings.",
|
'webkit': "Webkit settings.",
|
||||||
@ -187,6 +188,16 @@ DATA = OrderedDict([
|
|||||||
"Use {} for the filename. Gets split via shutils."),
|
"Use {} for the filename. Gets split via shutils."),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
|
('network', sect.KeyValue(
|
||||||
|
('do-not-track',
|
||||||
|
SettingValue(types.Bool(), 'true'),
|
||||||
|
"Value to send in the DNT header."),
|
||||||
|
|
||||||
|
('accept-language',
|
||||||
|
SettingValue(types.String(), 'en-US,en'),
|
||||||
|
"Value to send in the accept-language header."),
|
||||||
|
)),
|
||||||
|
|
||||||
('completion', sect.KeyValue(
|
('completion', sect.KeyValue(
|
||||||
('show',
|
('show',
|
||||||
SettingValue(types.Bool(), 'true'),
|
SettingValue(types.Bool(), 'true'),
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
from PyQt5.QtNetwork import QNetworkAccessManager
|
from PyQt5.QtNetwork import QNetworkAccessManager
|
||||||
|
|
||||||
|
import qutebrowser.config.config as config
|
||||||
from qutebrowser.network.qutescheme import QuteSchemeHandler
|
from qutebrowser.network.qutescheme import QuteSchemeHandler
|
||||||
|
|
||||||
|
|
||||||
@ -63,6 +64,14 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
reply = self._scheme_handlers[scheme].createRequest(
|
reply = self._scheme_handlers[scheme].createRequest(
|
||||||
op, req, outgoing_data)
|
op, req, outgoing_data)
|
||||||
else:
|
else:
|
||||||
|
if config.get('network', 'do-not-track'):
|
||||||
|
dnt = '1'.encode('ascii')
|
||||||
|
else:
|
||||||
|
dnt = '0'.encode('ascii')
|
||||||
|
req.setRawHeader('DNT'.encode('ascii'), dnt)
|
||||||
|
req.setRawHeader('X-Do-Not-Track'.encode('ascii'), dnt)
|
||||||
|
req.setRawHeader('Accept-Language'.encode('ascii'),
|
||||||
|
config.get('network', 'accept-language'))
|
||||||
reply = super().createRequest(op, req, outgoing_data)
|
reply = super().createRequest(op, req, outgoing_data)
|
||||||
self._requests[id(reply)] = reply
|
self._requests[id(reply)] = reply
|
||||||
reply.destroyed.connect(lambda obj: self._requests.pop(id(obj)))
|
reply.destroyed.connect(lambda obj: self._requests.pop(id(obj)))
|
||||||
|
Loading…
Reference in New Issue
Block a user