From 4c4091b12c3b3a7a67ba2fe258498bcca764d796 Mon Sep 17 00:00:00 2001 From: Jeppe Fihl-Pearson Date: Thu, 1 Dec 2022 19:26:24 +0000 Subject: [PATCH] Fix DeprecationWarning raised by urllib3 1.26.13 (#246) * Fix DeprecationWarning raised by urllib3 1.26.13 urllib3 has started to emit a DeprecationWarning whenever HTTPResponse.getheaders() is called since version 1.26.13. This changes the one place where this is done to instead use HTTPResponse.headers instead, which is the recommend way of retrieving the headers going forwards. Signed-off-by: Jeppe Fihl-Pearson * Add CHANGELOG entry Signed-off-by: Jeppe Fihl-Pearson Signed-off-by: Jeppe Fihl-Pearson --- CHANGELOG.md | 2 +- opensearchpy/connection/http_urllib3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c509036..730a45e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Removed ### Fixed - +- Fixed DeprecationWarning emitted from urllib3 1.26.13+ ([#246](https://github.com/opensearch-project/opensearch-py/pull/246)) ### Security diff --git a/opensearchpy/connection/http_urllib3.py b/opensearchpy/connection/http_urllib3.py index 51a4f2d9..6fc09e72 100644 --- a/opensearchpy/connection/http_urllib3.py +++ b/opensearchpy/connection/http_urllib3.py @@ -273,7 +273,7 @@ class Urllib3HttpConnection(Connection): method, full_url, url, orig_body, response.status, raw_data, duration ) - return response.status, response.getheaders(), raw_data + return response.status, response.headers, raw_data def get_response_headers(self, response): return {header.lower(): value for header, value in response.headers.items()}