This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch
3037-support-custom-http-headers-in-python-client
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/3037-support-custom-http-headers-in-python-client by this push:
new 0f82037032 feat(#3037): Add custom HTTP header support to Python client
0f82037032 is described below
commit 0f820370325966c8b18a0134534077f3a7c5def9
Author: Dominik Riemer <[email protected]>
AuthorDate: Tue Jul 16 09:16:47 2024 +0200
feat(#3037): Add custom HTTP header support to Python client
---
.github/workflows/pr-validation.yml | 2 +-
streampipes-client-python/pyproject.toml | 2 +-
streampipes-client-python/streampipes/client/client.py | 1 +
streampipes-client-python/streampipes/client/config.py | 7 ++++++-
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/pr-validation.yml
b/.github/workflows/pr-validation.yml
index 350e9ef559..65e6d18942 100644
--- a/.github/workflows/pr-validation.yml
+++ b/.github/workflows/pr-validation.yml
@@ -141,7 +141,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python: [3.8, 3.9, "3.10", "3.11"]
+ python: [3.8, 3.9, "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
defaults:
run:
diff --git a/streampipes-client-python/pyproject.toml
b/streampipes-client-python/pyproject.toml
index 2e00a81a64..3be7ecc753 100644
--- a/streampipes-client-python/pyproject.toml
+++ b/streampipes-client-python/pyproject.toml
@@ -53,7 +53,7 @@ include = [
]
[tool.poetry.dependencies]
-python = ">3.8.1,<3.12"
+python = ">3.8.1,<3.13"
confluent-kafka = "~2, >=2.0.2"
nats-py = "~2, >=2.2"
pandas = ">=1.5, <3"
diff --git a/streampipes-client-python/streampipes/client/client.py
b/streampipes-client-python/streampipes/client/client.py
index c150b6d24c..374f68569d 100644
--- a/streampipes-client-python/streampipes/client/client.py
+++ b/streampipes-client-python/streampipes/client/client.py
@@ -137,6 +137,7 @@ class StreamPipesClient:
# 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
diff --git a/streampipes-client-python/streampipes/client/config.py
b/streampipes-client-python/streampipes/client/config.py
index 8149b3b0c1..eaca0a0d5d 100644
--- a/streampipes-client-python/streampipes/client/config.py
+++ b/streampipes-client-python/streampipes/client/config.py
@@ -20,7 +20,7 @@ Configuration class for the StreamPipes client.
"""
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Optional
__all__ = [
@@ -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
--------
@@ -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)
+
+