Skip to content

Commit

Permalink
feat(#3037): Add custom HTTP header support to Python client (#3038)
Browse files Browse the repository at this point in the history
* feat(#3037): Add custom HTTP header support to Python client

* Modify typing

* Remove Python 3.12 support
  • Loading branch information
dominikriemer authored Jul 16, 2024
1 parent 8e7d262 commit 56e7428
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions streampipes-client-python/streampipes/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __init__(
# this allows to centrally determine the behavior of all requests made
self.request_session = Session()
self.request_session.headers.update(self.http_headers)
self.request_session.headers.update(self.client_config.additional_headers)

self.logging_level = logging_level
self._set_up_logging(logging_level=self.logging_level) # type: ignore
Expand Down
9 changes: 7 additions & 2 deletions streampipes-client-python/streampipes/client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"""


from dataclasses import dataclass
from typing import Optional
from dataclasses import dataclass, field
from typing import Dict, Optional

__all__ = [
"StreamPipesClientConfig",
Expand Down Expand Up @@ -49,6 +49,8 @@ class StreamPipesClientConfig:
port: Optional[int]
Specifies the port under which the StreamPipes API is available,
e.g., `80` (with http) or `443` (with https)
additional_headers: Optional[Dict[str, str]]
Specifies additional HTTP headers that should be sent with each request, e.g., proxy headers
Examples
--------
Expand All @@ -61,3 +63,6 @@ class StreamPipesClientConfig:
host_address: str
https_disabled: Optional[bool] = False
port: Optional[int] = 80
additional_headers: Optional[Dict[str, str]] = field(default_factory=dict)


0 comments on commit 56e7428

Please sign in to comment.