Skip to content

Commit

Permalink
Fix saltstack#66194: Exchange HTTPClient by AsyncHTTPClient in salt.u…
Browse files Browse the repository at this point in the history
…tils.http
  • Loading branch information
krombel committed Apr 29, 2024
1 parent 8a78c2d commit 125b3fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog/66330.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http
13 changes: 7 additions & 6 deletions salt/utils/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
import tornado.httpclient
import tornado.httputil
import tornado.simple_httpclient
from tornado.httpclient import HTTPClient
from tornado.httpclient import AsyncHTTPClient

import salt.config
import salt.loader
import salt.syspaths
import salt.utils.args
from salt.utils.asynchronous import SyncWrapper
import salt.utils.data
import salt.utils.files
import salt.utils.json
Expand Down Expand Up @@ -598,7 +599,7 @@ def query(
salt.config.DEFAULT_MINION_OPTS["http_request_timeout"],
)

tornado.httpclient.AsyncHTTPClient.configure(None)
AsyncHTTPClient.configure(None)
client_argspec = salt.utils.args.get_function_argspec(
tornado.simple_httpclient.SimpleAsyncHTTPClient.initialize
)
Expand Down Expand Up @@ -629,10 +630,10 @@ def query(
req_kwargs = salt.utils.data.decode(req_kwargs, to_str=True)

try:
download_client = (
HTTPClient(max_body_size=max_body)
if supports_max_body_size
else HTTPClient()
download_client = SyncWrapper(
AsyncHTTPClient,
kwargs={"max_body_size": max_body} if supports_max_body_size else {},
async_methods=["fetch"]
)
result = download_client.fetch(url_full, **req_kwargs)
except tornado.httpclient.HTTPError as exc:
Expand Down

0 comments on commit 125b3fb

Please sign in to comment.