Skip to content
Snippets Groups Projects
Commit ab862e16 authored by Gavin M. Roy's avatar Gavin M. Roy
Browse files

Dont overwrite host and change fetch body default

parent f4372226
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,6 +3,11 @@
Version History
===============
 
0.7.0 (2017-06-02)
------------------
- Don't overwrite the ``Host`` HTTP header if it's set
- Change fetch body arg default to None
0.6.0 (2017-04-18)
------------------
- Add support for using ``curl_httpclient.CurlAsyncHTTPClient``
Loading
Loading
import json
import logging
import pprint
import tornado_aws
from tornado import gen, ioloop
HEADERS = {'Content-Type': 'application/x-amz-json-1.0',
'x-amz-target': 'DynamoDB_20120810.DescribeTable'}
PAYLOAD = {'TableName': 'prod-us-east-1-history'}
@gen.coroutine
def async_request():
client = tornado_aws.AsyncAWSClient('dynamodb', use_curl=True)
response = yield client.fetch('POST', '/', headers=HEADERS,
body=json.dumps(PAYLOAD))
x = json.loads(response.body.decode('utf-8'))
pprint.pprint(x)
ioloop.IOLoop.instance().stop()
logging.basicConfig(level=logging.DEBUG)
_ioloop = ioloop.IOLoop.instance()
_ioloop.add_callback(async_request)
_ioloop.start()
Loading
Loading
@@ -39,7 +39,7 @@ def read_requirements(name):
 
setuptools.setup(
name='tornado-aws',
version='0.6.0',
version='0.7.0',
description=DESC,
long_description=open('README.rst').read(),
author='Gavin M. Roy',
Loading
Loading
Loading
Loading
@@ -6,6 +6,6 @@ from tornado_aws.client import AWSClient
from tornado_aws.client import AsyncAWSClient
from tornado_aws.client import exceptions
 
__version__ = '0.6.0'
__version__ = '0.7.0'
 
__all__ = ['AWSClient', 'AsyncAWSClient', 'exceptions']
Loading
Loading
@@ -303,10 +303,11 @@ class AWSClient(object):
headers.update({
'Content-Length': str(len(body)),
'Date': amz_date,
'Host': self._host,
'X-Amz-Content-sha256': payload_hash
})
 
headers.setdefault('Host', self._host)
# Temporary auth security token
if self._auth_config.security_token:
headers['X-Amz-Security-Token'] = self._auth_config.security_token
Loading
Loading
@@ -468,7 +469,7 @@ class AsyncAWSClient(AWSClient):
return httpclient.AsyncHTTPClient(max_clients=self._max_clients,
force_instance=True)
 
def fetch(self, method, path='/', query_args=None, headers=None, body=b'',
def fetch(self, method, path='/', query_args=None, headers=None, body=None,
_recursed=False):
"""Executes a request, returning an
:py:class:`HTTPResponse <tornado.httpclient.HTTPResponse>`.
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment