Skip to content

Commit

Permalink
set custom "User-Agent" for ExApps (#329)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bigcat88 authored Jan 19, 2025
1 parent 301296d commit 19fe459
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nc_py_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from os import environ

from httpx import AsyncClient, Client, Headers, Limits, ReadTimeout, Request, Response
from httpx import __version__ as httpx_version
from starlette.requests import HTTPConnection

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

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

Expand Down

0 comments on commit 19fe459

Please sign in to comment.