def _key_response_get(self, bucket_name, query, key_name, headers):
    self._set_action('KEY', 'GET', query)
    self._authenticate_and_authorize_s3_action()
    response_headers = {}
    if query.get('uploadId'):
        upload_id = query['uploadId'][0]
        part_number_marker = int(query.get('part-number-marker', [0])[0])
        if (not (0 <= part_number_marker <= 2147483647)):
            raise InvalidMaxPartArgument('part-number-marker', 0, 2147483647)
        max_parts = int(query.get('max-parts', [1000])[0])
        if (not (0 <= max_parts <= 2147483647)):
            raise InvalidMaxPartArgument('max-parts', 0, 2147483647)
        parts = self.backend.list_parts(bucket_name, upload_id, part_number_marker=part_number_marker, max_parts=max_parts)
        next_part_number_marker = ((parts[(- 1)].name + 1) if parts else 0)
        is_truncated = (parts and self.backend.is_truncated(bucket_name, upload_id, next_part_number_marker))
        template = self.response_template(S3_MULTIPART_LIST_RESPONSE)
        return (200, response_headers, template.render(bucket_name=bucket_name, key_name=key_name, upload_id=upload_id, is_truncated=str(is_truncated).lower(), max_parts=max_parts, next_part_number_marker=next_part_number_marker, parts=parts, part_number_marker=part_number_marker))
    version_id = query.get('versionId', [None])[0]
    if_modified_since = headers.get('If-Modified-Since', None)
    if_match = headers.get('If-Match', None)
    if_none_match = headers.get('If-None-Match', None)
    if_unmodified_since = headers.get('If-Unmodified-Since', None)
    key = self.backend.get_object(bucket_name, key_name, version_id=version_id)
    if ((key is None) and (version_id is None)):
        raise MissingKey(key_name)
    elif (key is None):
        raise MissingVersion()
    if if_unmodified_since:
        if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
        if (key.last_modified > if_unmodified_since):
            raise PreconditionFailed('If-Unmodified-Since')
    if (if_match and (key.etag not in [if_match, '"{0}"'.format(if_match)])):
        raise PreconditionFailed('If-Match')
    if if_modified_since:
        if_modified_since = str_to_rfc_1123_datetime(if_modified_since)
        if (key.last_modified < if_modified_since):
            return (304, response_headers, 'Not Modified')
    if (if_none_match and (key.etag == if_none_match)):
        return (304, response_headers, 'Not Modified')
    if ('acl' in query):
        acl = s3_backend.get_object_acl(key)
        template = self.response_template(S3_OBJECT_ACL_RESPONSE)
        return (200, response_headers, template.render(acl=acl))
    if ('tagging' in query):
        tags = self.backend.get_object_tagging(key)['Tags']
        template = self.response_template(S3_OBJECT_TAGGING_RESPONSE)
        return (200, response_headers, template.render(tags=tags))
    if ('legal-hold' in query):
        legal_hold = self.backend.get_object_legal_hold(key)
        template = self.response_template(S3_OBJECT_LEGAL_HOLD)
        return (200, response_headers, template.render(legal_hold=legal_hold))
    response_headers.update(key.metadata)
    response_headers.update(key.response_dict)
    return (200, response_headers, key.value)
def _key_response_get(self, bucket_name, query, key_name, headers):
    self._set_action('KEY', 'GET', query)
    self._authenticate_and_authorize_s3_action()
    response_headers = {}
    if query.get('uploadId'):
        upload_id = query['uploadId'][0]
        part_number_marker = int(query.get('part-number-marker', [0])[0])
        if (not (0 <= part_number_marker <= 2147483647)):
            raise InvalidMaxPartArgument('part-number-marker', 0, 2147483647)
        max_parts = int(query.get('max-parts', [1000])[0])
        if (not (0 <= max_parts <= 2147483647)):
            raise InvalidMaxPartArgument('max-parts', 0, 2147483647)
        parts = self.backend.list_parts(bucket_name, upload_id, part_number_marker=part_number_marker, max_parts=max_parts)
        next_part_number_marker = ((parts[(- 1)].name + 1) if parts else 0)
        is_truncated = (parts and self.backend.is_truncated(bucket_name, upload_id, next_part_number_marker))
        template = self.response_template(S3_MULTIPART_LIST_RESPONSE)
        return (200, response_headers, template.render(bucket_name=bucket_name, key_name=key_name, upload_id=upload_id, is_truncated=str(is_truncated).lower(), max_parts=max_parts, next_part_number_marker=next_part_number_marker, parts=parts, part_number_marker=part_number_marker))
    version_id = query.get('versionId', [None])[0]
    if_modified_since = headers.get('If-Modified-Since', None)
    if_match = headers.get('If-Match', None)
    if_none_match = headers.get('If-None-Match', None)
    if_unmodified_since = headers.get('If-Unmodified-Since', None)
    key = self.backend.get_object(bucket_name, key_name, version_id=version_id)
    if ((key is None) and (version_id is None)):
        raise MissingKey(key_name)
    elif (key is None):
        raise MissingVersion()
    if if_unmodified_since:
        if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
        if (key.last_modified > if_unmodified_since):
            raise PreconditionFailed('If-Unmodified-Since')
    if (if_match and (key.etag not in [if_match, '"{0}"'.format(if_match)])):
        raise PreconditionFailed('If-Match')
    if if_modified_since:
        if_modified_since = str_to_rfc_1123_datetime(if_modified_since)
        if (key.last_modified < if_modified_since):
            return (304, response_headers, 'Not Modified')
    if (if_none_match and (key.etag == if_none_match)):
        return (304, response_headers, 'Not Modified')
    if ('acl' in query):
        acl = s3_backend.get_object_acl(key)
        template = self.response_template(S3_OBJECT_ACL_RESPONSE)
        return (200, response_headers, template.render(acl=acl))
    if ('tagging' in query):
        tags = self.backend.get_object_tagging(key)['Tags']
        template = self.response_template(S3_OBJECT_TAGGING_RESPONSE)
        return (200, response_headers, template.render(tags=tags))
    if ('legal-hold' in query):
        legal_hold = self.backend.get_object_legal_hold(key)
        template = self.response_template(S3_OBJECT_LEGAL_HOLD)
        return (200, response_headers, template.render(legal_hold=legal_hold))
    response_headers.update(key.metadata)
    response_headers.update(key.response_dict)
    return (200, response_headers, key.value)