This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 56e742851d feat(#3037): Add custom HTTP header support to Python 
client (#3038)
56e742851d is described below

commit 56e742851dc30df41bb5d04b4fac307a6b1e066b
Author: Dominik Riemer <[email protected]>
AuthorDate: Tue Jul 16 12:27:23 2024 +0200

    feat(#3037): Add custom HTTP header support to Python client (#3038)
    
    * feat(#3037): Add custom HTTP header support to Python client
    
    * Modify typing
    
    * Remove Python 3.12 support
---
 streampipes-client-python/streampipes/client/client.py | 1 +
 streampipes-client-python/streampipes/client/config.py | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

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..336bcf5ece 100644
--- a/streampipes-client-python/streampipes/client/config.py
+++ b/streampipes-client-python/streampipes/client/config.py
@@ -20,8 +20,8 @@ Configuration class for the StreamPipes client.
 """
 
 
-from dataclasses import dataclass
-from typing import Optional
+from dataclasses import dataclass, field
+from typing import Dict, Optional
 
 __all__ = [
     "StreamPipesClientConfig",
@@ -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)
+
+

Reply via email to