Skip to content

Commit 4f1ab87

Browse files
authored
fix: logging http requests without query parameters (influxdata#631)
* fix: logging http requests without query parameters * docs: update CHANGELOG.md
1 parent d7181fa commit 4f1ab87

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### Bug Fixes
77
1. [#562](https://github.com/influxdata/influxdb-client-python/pull/562): Use `ThreadPoolScheduler` for `WriteApi`'s batch subject instead of `TimeoutScheduler` to prevent creating unnecessary threads repeatedly
8+
1. [#631](https://github.com/influxdata/influxdb-client-python/pull/631): Logging HTTP requests without query parameters
89

910
## 1.39.0 [2023-12-05]
1011

influxdb_client/_sync/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def request(self, method, url, query_params=None, headers=None,
170170
headers['Content-Type'] = 'application/json'
171171

172172
if self.configuration.debug:
173-
_BaseRESTClient.log_request(method, f"{url}?{urlencode(query_params)}")
173+
_BaseRESTClient.log_request(method, f"{url}{'' if query_params is None else '?' + urlencode(query_params)}")
174174
_BaseRESTClient.log_headers(headers, '>>>')
175175
_BaseRESTClient.log_body(body, '>>>')
176176

tests/test_InfluxDBClient.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,18 @@ def test_custom_debug_logging_handler(self):
415415
logger = logging.getLogger('influxdb_client.client.http')
416416
self.assertEqual(2, len(logger.handlers))
417417

418+
def test_debug_request_without_query_parameters(self):
419+
httpretty.register_uri(httpretty.GET, uri="http://localhost/ping", status=200, body="")
420+
self.influxdb_client = InfluxDBClient("http://localhost", "my-token", debug=True)
421+
422+
log_stream = StringIO()
423+
logger = logging.getLogger("influxdb_client.client.http")
424+
logger.addHandler(logging.StreamHandler(log_stream))
425+
426+
self.influxdb_client.api_client.call_api('/ping', 'GET')
427+
428+
self.assertIn("'GET http://localhost/ping'", log_stream.getvalue())
429+
418430

419431
class ServerWithSelfSingedSSL(http.server.SimpleHTTPRequestHandler):
420432
def _set_headers(self, response: bytes):

0 commit comments

Comments
 (0)
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