Skip to content

Commit

Permalink
Allows setting the User-Agent and defaults to the library + version
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog committed Jan 6, 2025
1 parent 040b7bd commit 3a9791e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gotenberg_client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from httpx import Client

from gotenberg_client.__about__ import __version__
from gotenberg_client._convert.chromium import ChromiumApi
from gotenberg_client._convert.libre_office import LibreOfficeApi
from gotenberg_client._convert.pdfa import PdfAApi
Expand Down Expand Up @@ -35,6 +36,7 @@ class GotenbergClient:
def __init__(
self,
host: str,
user_agent: str = f"gotenberg-client/{__version__}",
*,
timeout: float = 30.0,
log_level: int = logging.ERROR,
Expand All @@ -50,7 +52,7 @@ def __init__(
http2 (bool, optional): Whether to use HTTP/2. Defaults to True.
"""
# Configure the client
self._client = Client(base_url=host, timeout=timeout, http2=http2)
self._client = Client(base_url=host, timeout=timeout, http2=http2, headers={"User-Agent": user_agent})

# Set the log level
logging.getLogger("httpx").setLevel(log_level)
Expand Down

0 comments on commit 3a9791e

Please sign in to comment.