Linux maintainer tooling and workflows
 help / color / mirror / Atom feed
* [PATCH] mbox: Add support for proxied https connections
@ 2022-01-18 17:41 David Vernet
  2022-01-18 18:00 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 5+ messages in thread
From: David Vernet @ 2022-01-18 17:41 UTC (permalink / raw)
  To: konstantin; +Cc: users, tools, void

The mbox subsystem uses the python requests library to fetch a thread from
lore.kernel.org, by its message ID. This is extremely convenient, but
unfortunately doesn't work for users who must redirect their http(s)
traffic through a proxy to access the internet.

This diff therefore adds support for querying 'http.proxy' from their git
config, and when set, passing that as a proxy entry to the underlying
session requests object.

Signed-off-by: David Vernet <void@manifault.com>
---
 b4/__init__.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/b4/__init__.py b/b4/__init__.py
index 11c287e..0526a19 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -138,6 +138,8 @@ DEFAULT_CONFIG = {
 MAIN_CONFIG = None
 # This is git-config user.*
 USER_CONFIG = None
+# This is git-config http.*
+HTTP_CONFIG = None
 
 # Used for storing our requests session
 REQSESSION = None
@@ -2101,12 +2103,21 @@ def get_user_config():
             USER_CONFIG['name'] = udata.pw_gecos
     return USER_CONFIG
 
+def get_http_config():
+    global HTTP_CONFIG
+    if HTTP_CONFIG is None:
+        HTTP_CONFIG = get_config_from_git(r'http\..*')
+    return HTTP_CONFIG
 
 def get_requests_session():
     global REQSESSION
     if REQSESSION is None:
         REQSESSION = requests.session()
         REQSESSION.headers.update({'User-Agent': 'b4/%s' % __VERSION__})
+        http_config = get_http_config()
+        if 'proxy' in http_config:
+            REQSESSION.proxies.update({'https': http_config['proxy']})
+
     return REQSESSION
 
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-18 19:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18 17:41 [PATCH] mbox: Add support for proxied https connections David Vernet
2022-01-18 18:00 ` Konstantin Ryabitsev
2022-01-18 18:14   ` David Vernet
2022-01-18 18:28     ` Konstantin Ryabitsev
2022-01-18 19:42       ` David Vernet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox