Skip to content

Commit 8b1a4b2

Browse files
authored
Disallow unicode headers for urllib3
1 parent 47e8d15 commit 8b1a4b2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

elasticsearch/connection/http_urllib3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from urllib3.exceptions import SSLError as UrllibSSLError # type: ignore
2525
from urllib3.util.retry import Retry # type: ignore
2626

27-
from ..compat import reraise_exceptions, urlencode
27+
from ..compat import reraise_exceptions, to_str, urlencode
2828
from ..exceptions import (
2929
ConnectionError,
3030
ConnectionTimeout,
@@ -243,6 +243,10 @@ def perform_request(
243243

244244
request_headers = self.headers.copy()
245245
request_headers.update(headers or ())
246+
request_headers = {
247+
to_str(header, "latin-1"): to_str(value, "latin-1")
248+
for header, value in request_headers.items()
249+
}
246250

247251
if self.http_compress and body:
248252
body = self._gzip_compress(body)

0 commit comments

Comments
 (0)