def _key_response(self, request, full_url, headers):
    parsed_url = urlparse(full_url)
    query = parse_qs(parsed_url.query, keep_blank_values=True)
    method = request.method
    key_name = self.parse_key_name(request, parsed_url.path)
    bucket_name = self.parse_bucket_name_from_url(request, full_url)
    if ('Authorization' not in request.headers):
        if hasattr(request, 'url'):
            signed_url = ('Signature=' in request.url)
        elif hasattr(request, 'requestline'):
            signed_url = ('Signature=' in request.path)
        key = self.backend.get_object(bucket_name, key_name)
        if key:
            if ((not key.acl.public_read) and (not signed_url)):
                return (403, {}, '')
        elif signed_url:
            if self._invalid_headers(request.url, dict(request.headers)):
                return (403, {}, S3_INVALID_PRESIGNED_PARAMETERS)
    if hasattr(request, 'body'):
        body = request.body
        if hasattr(body, 'read'):
            body = body.read()
    else:
        body = request.data
        if (not body):
            if request.files:
                for (_, value) in request.files.items():
                    body = value.stream.read()
            elif hasattr(request, 'form'):
                form = request.form
                for (k, _) in form.items():
                    body = k
    if (body is None):
        body = b''
    if (request.headers.get('x-amz-content-sha256', None) == 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'):
        body = self._handle_v4_chunk_signatures(body, int(request.headers['x-amz-decoded-content-length']))
    if (method == 'GET'):
        return self._key_response_get(bucket_name, query, key_name, headers=request.headers)
    elif (method == 'PUT'):
        return self._key_response_put(request, body, bucket_name, query, key_name, headers)
    elif (method == 'HEAD'):
        return self._key_response_head(bucket_name, query, key_name, headers=request.headers)
    elif (method == 'DELETE'):
        return self._key_response_delete(headers, bucket_name, query, key_name)
    elif (method == 'POST'):
        return self._key_response_post(request, body, bucket_name, query, key_name)
    else:
        raise NotImplementedError('Method {0} has not been implemented in the S3 backend yet'.format(method))
def _key_response(self, request, full_url, headers):
    parsed_url = urlparse(full_url)
    query = parse_qs(parsed_url.query, keep_blank_values=True)
    method = request.method
    key_name = self.parse_key_name(request, parsed_url.path)
    bucket_name = self.parse_bucket_name_from_url(request, full_url)
    if ('Authorization' not in request.headers):
        if hasattr(request, 'url'):
            signed_url = ('Signature=' in request.url)
        elif hasattr(request, 'requestline'):
            signed_url = ('Signature=' in request.path)
        key = self.backend.get_object(bucket_name, key_name)
        if key:
            if ((not key.acl.public_read) and (not signed_url)):
                return (403, {}, )
        elif signed_url:
            if self._invalid_headers(request.url, dict(request.headers)):
                return (403, {}, S3_INVALID_PRESIGNED_PARAMETERS)
    if hasattr(request, 'body'):
        body = request.body
        if hasattr(body, 'read'):
            body = body.read()
    else:
        body = request.data
        if (not body):
            if request.files:
                for (_, value) in request.files.items():
                    body = value.stream.read()
            elif hasattr(request, 'form'):
                form = request.form
                for (k, _) in form.items():
                    body = k
    if (body is None):
        body = b
    if (request.headers.get('x-amz-content-sha256', None) == 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'):
        body = self._handle_v4_chunk_signatures(body, int(request.headers['x-amz-decoded-content-length']))
    if (method == 'GET'):
        return self._key_response_get(bucket_name, query, key_name, headers=request.headers)
    elif (method == 'PUT'):
        return self._key_response_put(request, body, bucket_name, query, key_name, headers)
    elif (method == 'HEAD'):
        return self._key_response_head(bucket_name, query, key_name, headers=request.headers)
    elif (method == 'DELETE'):
        return self._key_response_delete(headers, bucket_name, query, key_name)
    elif (method == 'POST'):
        return self._key_response_post(request, body, bucket_name, query, key_name)
    else:
        raise NotImplementedError('Method {0} has not been implemented in the S3 backend yet'.format(method))