Skip to content

Commit 19fe459

Browse files
authored
set custom "User-Agent" for ExApps (#329)
Fixes #327 Changes proposed in this pull request: * Added a custom header in the format `ExApp/test-deploy/1.1.0 (httpx/0.24.1)` to help "system administrators" identify which requests are taking a long time to complete.
1 parent 301296d commit 19fe459

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

nc_py_api/_session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from os import environ
1313

1414
from httpx import AsyncClient, Client, Headers, Limits, ReadTimeout, Request, Response
15+
from httpx import __version__ as httpx_version
1516
from starlette.requests import HTTPConnection
1617

1718
from . import options
@@ -511,6 +512,7 @@ def _create_adapter(self, dav: bool = False) -> AsyncClient | Client:
511512
"AA-VERSION": self.cfg.aa_version,
512513
"EX-APP-ID": self.cfg.app_name,
513514
"EX-APP-VERSION": self.cfg.app_version,
515+
"user-agent": f"ExApp/{self.cfg.app_name}/{self.cfg.app_version} (httpx/{httpx_version})",
514516
},
515517
)
516518

@@ -535,6 +537,7 @@ def _create_adapter(self, dav: bool = False) -> AsyncClient | Client:
535537
"AA-VERSION": self.cfg.aa_version,
536538
"EX-APP-ID": self.cfg.app_name,
537539
"EX-APP-VERSION": self.cfg.app_version,
540+
"User-Agent": f"ExApp/{self.cfg.app_name}/{self.cfg.app_version} (httpx/{httpx_version})",
538541
},
539542
)
540543

0 commit comments

Comments
 (0)