Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1097,13 +1097,20 @@ with InfluxDBClient(url="http://localhost:8086",

If your proxy notify the client with permanent redirect (`HTTP 301`) to **different host**. The client removes `Authorization` header, because otherwise the contents of `Authorization` is sent to third parties which is a security vulnerability.

You can change this behaviour by:
You can change this behavior by doing this in older urllib3 versions:
Comment thread
NguyenHoangSon96 marked this conversation as resolved.
Outdated

``` python
from urllib3 import Retry
Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset()
Retry.DEFAULT.remove_headers_on_redirect = Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT
```
In the newer urllib3 versions, try to use this:

``` python
retries = Retry(redirect=1, remove_headers_on_redirect=[])
self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org", retries=retries)
```

<!-- marker-proxy-end -->

### Delete data
Expand Down
10 changes: 10 additions & 0 deletions influxdb_client/client/flux_csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ def _prepare_data_frame(self):

# We have to create temporary DataFrame because we want to preserve default column values
_temp_df = pd.DataFrame(self._data_frame_values)
# This is for backward compatibles reason
# In newer Pandas versions 'string' type will be 'str', in older versions 'string' type will be 'object'
# In newer Pandas versions 'time' will be 'datetime64[us, UTC]', in older versions 'time'
# will be 'datetime64[ns, UTC]'
for column in _temp_df.columns:
if _temp_df[column].dtype.name == 'str':
_temp_df[column] = _temp_df[column].astype(object)
if _temp_df[column].dtype.name == 'datetime64[us, UTC]':
_temp_df[column] = _temp_df[column].astype('datetime64[ns, UTC]')

self._data_frame_values = []

# Custom DataFrame index
Expand Down
5 changes: 4 additions & 1 deletion tests/test_WriteApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ def test_redirect(self):
Retry.DEFAULT.remove_headers_on_redirect = Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT
self.influxdb_client.close()

self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org")
# In the newer urllib3 versions we need to set `redirect` and `remove_headers_on_redirect=[]` to
# make it re-direct POST requests and stop it from remove the `Authorization` header.
retries = Retry(redirect=1, remove_headers_on_redirect=[])
self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org", retries=retries)

httpretty.register_uri(httpretty.POST, uri="http://localhost2/api/v2/write", status=204)
httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=301,
Expand Down
Loading