Print user agent and http proxy if set

This commit is contained in:
Schimon Jehudah 2024-03-13 16:17:43 +00:00
parent 3c89b84908
commit f18659fd88
2 changed files with 6 additions and 4 deletions

View file

@ -190,6 +190,9 @@ def main():
config_dir = config.get_default_config_directory()
logging.info('Reading configuration from {}'.format(config_dir))
print('Reading configuration from {}'.format(config_dir))
network_settings = config.get_values('settings.toml', 'network')
print('User agent:', network_settings['user_agent'] or 'Slixfeed/0.1')
if network_settings['http_proxy']: print('HTTP Proxy:', network_settings['http_proxy'])
# values = config.get_value('accounts', 'XMPP Proxy',
# ['socks5_host', 'socks5_port'])

View file

@ -119,11 +119,10 @@ async def http(url):
msg: list or str
Document or error message.
"""
user_agent = (config.get_values('settings.toml', 'network')['user_agent']
or 'Slixfeed/0.1')
network_settings = config.get_values('settings.toml', 'network')
user_agent = (network_settings['user_agent'] or 'Slixfeed/0.1')
headers = {'User-Agent': user_agent}
proxy = (config.get_values('settings.toml', 'network')['http_proxy']
or None)
proxy = (network_settings['http_proxy'] or None)
timeout = ClientTimeout(total=10)
async with ClientSession(headers=headers) as session:
# async with ClientSession(trust_env=True) as session: