Skip to content

Commit

Permalink
mv UA to own func
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz committed Oct 30, 2024
1 parent bf5310b commit 44e5d30
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion garak/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ def _store_config(settings_files) -> None:
reporting = _set_settings(reporting, settings["reporting"])


def _garak_user_agent(dummy=None):
global run
if hasattr(run, "user_agent"):
return run.user_agent
else:
return "garak"


def set_all_http_lib_agents(agent_string):
set_http_lib_agents(
{"requests": agent_string, "httpx": agent_string, "aiohttp": agent_string}
Expand All @@ -165,7 +173,7 @@ def set_http_lib_agents(agent_strings: dict):
if "requests" in agent_strings:
from requests import utils

utils.default_user_agent = lambda x=None: agent_strings["requests"]
utils.default_user_agent = _garak_user_agent
if "httpx" in agent_strings:
import httpx

Expand Down

0 comments on commit 44e5d30

Please sign in to comment.