diff --git a/botocore/auth.py b/botocore/auth.py index 7351fd5d41..f9fac833fe 100644 --- a/botocore/auth.py +++ b/botocore/auth.py @@ -30,7 +30,6 @@ encodebytes, ensure_unicode, parse_qs, - parse_qsl, quote, unquote, urlsplit, @@ -165,8 +164,6 @@ def add_auth(self, request): if request.data: # POST params = request.data - if not isinstance(params, dict): - params = dict(parse_qsl(params)) else: # GET params = request.params diff --git a/botocore/handlers.py b/botocore/handlers.py index dcb814640b..b848014fae 100644 --- a/botocore/handlers.py +++ b/botocore/handlers.py @@ -1148,14 +1148,18 @@ def remove_content_type_header_for_presigning(request, **kwargs): del request.headers['Content-Type'] -def urlencode_body(model, params, **kwargs): +def urlencode_body(model, params, context, **kwargs): """Urlencode the request body if it is a dictionary. This is used for services like S3 that require the body to be urlencoded when the body is a dictionary. """ body = params.get('body') - if model.service_model.protocol == 'query' and isinstance(body, dict): + if ( + context['client_config'].signature_version != 'v2' + and model.service_model.protocol == 'query' + and isinstance(body, dict) + ): params['body'] = urlencode(body, doseq=True, encoding='utf-8').encode( 'utf-8' ) @@ -1163,7 +1167,12 @@ def urlencode_body(model, params, **kwargs): def compress_request(model, params, context, **kwargs): body = params.get('body') - if model.request_compression and body is not None: + config = context['client_config'] + if config.signature_version == 'v2': + logger.debug( + "Request compression is not supported for signature version 2" + ) + elif model.request_compression and body is not None: AWS_REQUEST_COMPRESSOR.compress(body, context['client_config'], model)