From 62f8b47e61c74b81a11f2268f8ccfd27c9ca63a8 Mon Sep 17 00:00:00 2001 From: Tasos Sahanidis Date: Sun, 12 Jan 2020 03:29:11 +0200 Subject: [PATCH] Add supybot.protocols.http.requestLanguage --- src/conf.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/conf.py b/src/conf.py index 4f59c794b..421e77f7d 100644 --- a/src/conf.py +++ b/src/conf.py @@ -1299,6 +1299,23 @@ registerGlobalValue(supybot.protocols.http, 'proxy', through. The value should be of the form 'host:port'."""))) utils.web.proxy = supybot.protocols.http.proxy +class HttpRequestLanguage(registry.String): + """Must be a valid HTTP Accept-Language value.""" + __slots__ = () + def setValue(self, v): + headers = utils.web.defaultHeaders + lkey = 'Accept-Language' + if v: + headers[lkey] = v + elif lkey in headers: + del headers[lkey] + super(HttpRequestLanguage, self).setValue(v) + +registerChannelValue(supybot.protocols.http, 'requestLanguage', + HttpRequestLanguage('', _("""If set, the Accept-Language HTTP header will be set to this + value for requests. Useful for overriding the auto-detected language based on + the server's location."""))) + ### # supybot.protocols.ssl ###