Skip to content

Commit fc8ab2b

Browse files
committed
Added support for explicit proxy to RequestsHttpConnection
Signed-off-by: Filipe Pina <[email protected]>
1 parent 1a18e58 commit fc8ab2b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1010
- Small refactor of AWS Signer classes for both sync and async clients ([866](https://github.com/opensearch-project/opensearch-py/pull/866))
1111
- Small refactor to fix overwriting the module files when generating apis ([874](https://github.com/opensearch-project/opensearch-py/pull/874))
1212
- Fixed a "type ignore" lint error
13+
- Added support for explicit proxy to RequestsHttpConnection ([908](https://github.com/opensearch-project/opensearch-py/pull/908))
1314
### Deprecated
1415
### Removed
1516
### Fixed

opensearchpy/connection/http_requests.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import time
2929
import warnings
30-
from typing import Any, Collection, Mapping, Optional, Union
30+
from typing import Any, Collection, Dict, Mapping, Optional, Union
3131

3232
try:
3333
import requests
@@ -74,6 +74,7 @@ class RequestsHttpConnection(Connection):
7474
:arg metrics: metrics is an instance of a subclass of the
7575
:class:`~opensearchpy.Metrics` class, used for collecting
7676
and reporting metrics related to the client's operations;
77+
:arg proxies: optional dictionary mapping protocol to the URL of the proxy.
7778
"""
7879

7980
def __init__(
@@ -92,6 +93,7 @@ def __init__(
9293
opaque_id: Any = None,
9394
pool_maxsize: Any = None,
9495
metrics: Metrics = MetricsNone(),
96+
proxies: Optional[Dict[str, str]] = None,
9597
**kwargs: Any,
9698
) -> None:
9799
self.metrics = metrics
@@ -132,6 +134,9 @@ def __init__(
132134
http_auth = tuple(http_auth.split(":", 1)) # type: ignore
133135
self.session.auth = http_auth
134136

137+
if proxies is not None:
138+
self.session.proxies = proxies
139+
135140
self.base_url = f"{self.host}{self.url_prefix}"
136141
self.session.verify = verify_certs
137142
if not client_key:

0 commit comments

Comments
 (0)