Skip to content

Commit

Permalink
Allows setting a user agent for the client
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog committed Jan 6, 2025
1 parent 0aff0ff commit 17173b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Allow setting user agent string and provide a default ([#34](https://github.com/stumpylog/tika-client/pull/34))

## [0.8.1] - 2024-12-17

### Fixed
Expand Down
6 changes: 4 additions & 2 deletions src/tika_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from httpx import Client

from tika_client.__about__ import __version__
from tika_client._resource_meta import Metadata
from tika_client._resource_recursive import Recursive
from tika_client._resource_tika import Tika
Expand All @@ -22,14 +23,15 @@
class TikaClient:
def __init__(
self,
*,
tika_url: str,
user_agent: str = f"tika-client/{__version__}",
*,
timeout: float = 30.0,
log_level: int = logging.ERROR,
compress: bool = False,
):
# Configure the client
self._client = Client(base_url=tika_url, timeout=timeout)
self._client = Client(base_url=tika_url, timeout=timeout, headers={"User-Agent": user_agent})

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

0 comments on commit 17173b8

Please sign in to comment.