diff --git a/src/rest_vol.h b/src/rest_vol.h index 656aa734..d866808a 100644 --- a/src/rest_vol.h +++ b/src/rest_vol.h @@ -770,6 +770,8 @@ herr_t RV_convert_datatype_to_JSON(hid_t type_id, char **type_body, size_t *type #define SERVER_VERSION_SUPPORTS_FIXED_LENGTH_UTF8(version) \ (SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 5)) +#define SERVER_VERSION_SUPPORTS_LONG_URLS(version) (SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 5)) + #ifdef __cplusplus } #endif diff --git a/src/rest_vol_link.c b/src/rest_vol_link.c index 0935799d..01e17afd 100644 --- a/src/rest_vol_link.c +++ b/src/rest_vol_link.c @@ -330,6 +330,11 @@ RV_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t new_link_loc_obj->URI, url_encoded_link_name)) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(new_link_loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "link create URL size exceeded maximum URL size"); @@ -542,6 +547,12 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR( + H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "H5Lget_info request URL size exceeded maximum URL size"); @@ -653,6 +664,11 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "H5Lget_name_by_idx request URL size exceeded maximum URL size"); @@ -760,6 +776,12 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR( + H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "H5Lget_val request URL size exceeded maximum URL size"); @@ -938,6 +960,12 @@ RV_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_speci 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR( + H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "H5Ldelete request URL size exceeded maximum URL size"); @@ -1036,6 +1064,11 @@ RV_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_speci empty_dirname ? loc_obj->URI : temp_URI, url_encoded_link_name)) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "H5Lexists request URL size exceeded maximum URL size"); @@ -1121,6 +1154,12 @@ RV_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_speci loc_obj->URI)) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR( + H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "H5Literate/visit request URL size exceeded maximum URL size"); @@ -1157,6 +1196,12 @@ RV_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_speci ((RV_object_t *)link_iter_group_object)->URI)) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(loc_obj->domain->u.file.server_version)) && + (url_len >= OLD_URL_MAX_LENGTH)) + FUNC_GOTO_ERROR( + H5E_LINK, H5E_UNSUPPORTED, FAIL, + "URL with length > 2048 not supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR( H5E_LINK, H5E_SYSERRSTR, FAIL, @@ -2020,6 +2065,11 @@ RV_build_link_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func)( url_encoded_link_name)) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "snprintf error"); + // if (!(SERVER_VERSION_SUPPORTS_LONG_URLS(???->domain->u.file.server_version)) + // && (url_len >= OLD_URL_MAX_LENGTH)) + // FUNC_GOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "URL with length > 2048 not + // supported by server versions before 0.8.5"); + if (url_len >= URL_MAX_LENGTH) FUNC_GOTO_ERROR(H5E_LINK, H5E_SYSERRSTR, FAIL, "link GET request URL size exceeded maximum URL size"); diff --git a/src/rest_vol_public.h b/src/rest_vol_public.h index f9cc163d..63f36b0e 100644 --- a/src/rest_vol_public.h +++ b/src/rest_vol_public.h @@ -27,6 +27,9 @@ */ #define URL_MAX_LENGTH ((64 * 1024) + 1024) + 2048 +/* Maximum URL length supported by server API versions <= 0.8.4 */ +#define OLD_URL_MAX_LENGTH 2048 + /* Maximum length in characters of the URI of an object as returned by the server. If the * server in question returns URIs which are longer than this, the value will have to be * adjusted. Otherwise, the URIs will be truncated and invalid, likely causing severe