def _key_response_head(self, bucket_name, query, key_name, headers):
    self._set_action('KEY', 'HEAD', query)
    self._authenticate_and_authorize_s3_action()
    response_headers = {}
    version_id = query.get('versionId', [None])[0]
    part_number = query.get('partNumber', [None])[0]
    if part_number:
        part_number = int(part_number)
    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.head_object(bucket_name, key_name, version_id=version_id, part_number=part_number)
    if key:
        response_headers.update(key.metadata)
        response_headers.update(key.response_dict)
        if if_unmodified_since:
            if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
            if (key.last_modified > if_unmodified_since):
                return (412, response_headers, '')
        if (if_match and (key.etag != if_match)):
            return (412, response_headers, '')
        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')
        return (200, response_headers, '')
    else:
        return (404, response_headers, '')
def _key_response_head(self, bucket_name, query, key_name, headers):
    self._set_action('KEY', 'HEAD', query)
    self._authenticate_and_authorize_s3_action()
    response_headers = {}
    version_id = query.get('versionId', [None])[0]
    part_number = query.get('partNumber', [None])[0]
    if part_number:
        part_number = int(part_number)
    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.head_object(bucket_name, key_name, version_id=version_id, part_number=part_number)
    if key:
        response_headers.update(key.metadata)
        response_headers.update(key.response_dict)
        if if_unmodified_since:
            if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)
            if (key.last_modified > if_unmodified_since):
                return (412, response_headers, )
        if (if_match and (key.etag != if_match)):
            return (412, response_headers, )
        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')
        return (200, response_headers, )
    else:
        return (404, response_headers, )