Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.43.0 [unreleased]

### Bug Fixes
1. [#655](https://github.com/influxdata/influxdb-client-python/pull/655): Replace deprecated `urllib` calls `HTTPResponse.getheaders()` and `HTTPResponse.getheader()`.

## 1.42.0 [2024-04-17]

### Bug Fixes
Expand Down
5 changes: 4 additions & 1 deletion influxdb_client/client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def __init__(self, response: HTTPResponse = None, message: str = None):
if response is not None:
self.response = response
self.message = self._get_message(response)
self.retry_after = response.getheader('Retry-After')
if isinstance(response, HTTPResponse): # response is HTTPResponse
self.retry_after = response.headers.get('Retry-After')
else: # response is RESTResponse
self.retry_after = response.getheader('Retry-After')
else:
self.response = None
self.message = message or 'no response'
Expand Down
7 changes: 5 additions & 2 deletions influxdb_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import logging
from typing import Dict

from urllib3 import HTTPResponse
from influxdb_client.client.exceptions import InfluxDBError
from influxdb_client.configuration import Configuration

Expand All @@ -34,7 +34,10 @@ def __init__(self, status=None, reason=None, http_resp=None):
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data
self.headers = http_resp.getheaders()
if isinstance(http_resp, HTTPResponse): # response is HTTPResponse
self.headers = http_resp.headers
else: # response is RESTResponse
self.headers = http_resp.getheaders()
else:
self.status = status
self.reason = reason
Expand Down