diff --git a/singer_sdk/streams/rest.py b/singer_sdk/streams/rest.py index c65ee3f56..956f61f46 100644 --- a/singer_sdk/streams/rest.py +++ b/singer_sdk/streams/rest.py @@ -107,7 +107,7 @@ def __init__( super().__init__(name=name, schema=schema, tap=tap) if path: self.path = path - self._http_headers: dict = {} + self._http_headers: dict = {"User-Agent": self.user_agent} self._requests_session = requests.Session() self._compiled_jsonpath = None self._next_page_token_compiled_jsonpath = None @@ -157,6 +157,15 @@ def requests_session(self) -> requests.Session: self._requests_session = requests.Session() return self._requests_session + @property + def user_agent(self) -> str: + """Get the user agent string for the stream. + + Returns: + The user agent string. + """ + return f"{self.tap_name}/{self._tap.plugin_version}" + def validate_response(self, response: requests.Response) -> None: """Validate HTTP response. @@ -560,10 +569,7 @@ def http_headers(self) -> dict: Returns: Dictionary of HTTP headers to use as a base for every request. """ - result = self._http_headers - if "user_agent" in self.config: - result["User-Agent"] = self.config.get("user_agent") - return result + return self._http_headers @property def timeout(self) -> int: