From 2f129c26fc1abccf821e6fb6185c47d02a6d4dab Mon Sep 17 00:00:00 2001 From: Robert Habermann Date: Sat, 7 Nov 2015 21:56:37 +0100 Subject: [PATCH] add option to use Requests http(s) proxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The influxdb-python client does not have support for a web proxy although the Requests library provides the possibility to use a web proxy for both http and https requests. This PR (optionally) adds the feature to use a http(s) proxy by adding an additional parameter to InfluxDBClient initialization called´"proxies". This parameter expects that a dict is provided. If this is not set it will default to { }. The syntax for the dict is the same as specified in Requests docs: http://docs.python-requests.org/en/latest/user/advanced/#proxies proxies = { "http": "http://10.10.1.10:3128", "https": "http://10.10.1.10:1080", } --- influxdb/client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/influxdb/client.py b/influxdb/client.py index 6c180ce4..eb79a552 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -55,6 +55,8 @@ class InfluxDBClient(object): :type use_udp: int :param udp_port: UDP port to connect to InfluxDB, defaults to 4444 :type udp_port: int + :param proxies: HTTP(S) proxy to use for Requests, defaults to {} + :type proxies: dict """ def __init__(self, @@ -68,6 +70,7 @@ def __init__(self, timeout=None, use_udp=False, udp_port=4444, + proxies=None, ): """Construct a new InfluxDBClient object.""" self._host = host @@ -90,6 +93,11 @@ def __init__(self, if ssl is True: self._scheme = "https" + if proxies is None: + self._proxies = {} + else: + self._proxies = proxies + self._baseurl = "{0}://{1}:{2}".format( self._scheme, self._host, @@ -229,6 +237,7 @@ def request(self, url, method='GET', params=None, data=None, params=params, data=data, headers=headers, + proxies=self._proxies, verify=self._verify_ssl, timeout=self._timeout ) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy