Merge pull request #26488 from cachedout/fix_unsupported_tornado_kwarg

Don't pass unsupported kwarg to tornado
This commit is contained in:
Mike Place 2015-08-19 16:54:47 -06:00
commit 103651d963

View File

@ -14,6 +14,7 @@ import os.path
import pprint
import socket
import urllib
import inspect
import ssl
try:
@ -403,20 +404,38 @@ def query(url,
max_body = opts.get('http_max_body', salt.config.DEFAULT_MINION_OPTS['http_max_body'])
timeout = opts.get('http_request_timeout', salt.config.DEFAULT_MINION_OPTS['http_request_timeout'])
client_argspec = inspect.getargspec(HTTPClient.__init__)
supports_max_body_size = 'kwargs' in client_argspec.keywords or 'max_body_size' in client_argspec.args
try:
result = HTTPClient(max_body_size=max_body).fetch(
url_full,
method=method,
headers=header_dict,
auth_username=username,
auth_password=password,
body=data,
validate_cert=verify_ssl,
allow_nonstandard_methods=True,
streaming_callback=streaming_callback,
request_timeout=timeout,
**req_kwargs
)
if supports_max_body_size:
result = HTTPClient(max_body_size=max_body).fetch(
url_full,
method=method,
headers=header_dict,
auth_username=username,
auth_password=password,
body=data,
validate_cert=verify_ssl,
allow_nonstandard_methods=True,
streaming_callback=streaming_callback,
request_timeout=timeout,
**req_kwargs
)
else:
result = HTTPClient().fetch(
url_full,
method=method,
headers=header_dict,
auth_username=username,
auth_password=password,
body=data,
validate_cert=verify_ssl,
allow_nonstandard_methods=True,
streaming_callback=streaming_callback,
request_timeout=timeout,
**req_kwargs
)
except tornado.httpclient.HTTPError as exc:
ret['status'] = exc.code
ret['error'] = str(exc)