I am working on a new hobby project RESTifying the ZFS APIs, Earlier I was using play framework for my REST projects, now started using SpringBoot
While RESTifying the ZFS API one of the API formats is like
@GetMapping(path = {"/", "/{poolname}", "/{poolname}/{volumename}"}, produces = "application/json")
/ will give all the pool name and volumes, /poolname will give all the pool name and volumes of that particular pool, /poolname/”poolname/volumename” should give the pool and the volume.
The volume name is in the format {poolname}/{volumename}, so I want to provide the slash with URL encoded but given restful method below gives HTTP Status 400 – Bad Request
GET http://zfsappliance:8080/zfs/sql-pool/sql-pool%2Fdisk1
Accept: application/json
</head>
<body><h1>HTTP Status 400 – Bad Request</h1></body>
</html>
Without the %2F everything works fine.
Resolution
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper urlPathHelper = new UrlPathHelper();
urlPathHelper.setUrlDecode(false);
configurer.setUrlPathHelper(urlPathHelper);
}
By adding the above method in the main function, I am able to get the response correctly.
GET http://10.10.109.81:8080/zfs/sql-pool/sql-pool%2Fdisk1
Accept: application/json
[
{
"name": "sql-pool",
"type": "FILESYSTEM",
"properties": {
"ZFS_PROP_USED": "10855528448",
"ZFS_PROP_TYPE": "filesystem",
"ZFS_PROP_SETUID": "on",
"ZFS_PROP_CASE": "off",
"ZFS_PROP_VERSION": "off",
"ZFS_PROP_MOUNTED": "yes",
"ZFS_PROP_REFQUOTA": "0",
"ZFS_PROP_COMPRESSRATIO": "1.00",
"ZFS_PROP_READONLY": "off",
"ZFS_PROP_CREATETXG": "1",
"ZFS_PROP_UTF8ONLY": "none",
"ZFS_PROP_DEVICES": "on",
"ZFS_NUM_PROPS": "all",
"ZFS_PROP_RESERVATION": "0",
"ZFS_PROP_ZONED": "off",
"ZFS_PROP_NUMCLONES": "1",
"ZFS_PROP_CHECKSUM": "on",
"ZFS_PROP_CREATION": "1565873676",
"ZFS_PROP_REFERENCED": "24576",
"ZFS_PROP_NORMALIZE": "sensitive",
"ZFS_PROP_ACLINHERIT": "restricted",
"ZFS_PROP_QUOTA": "0",
"ZFS_PROP_VSCAN": "off",
"ZFS_PROP_SHARENFS": "off",
"ZFS_PROP_ATIME": "on",
"ZFS_PROP_RECORDSIZE": "131072",
"ZFS_PROP_ISCSIOPTIONS": "on",
"ZFS_PROP_EXEC": "on",
"ZFS_PROP_COMPRESSION": "off",
"ZFS_PROP_SHARESMB": "0",
"ZFS_PROP_NAME": "sql-pool",
"ZFS_PROP_MOUNTPOINT": "/sql-pool",
"ZFS_PROP_SNAPDIR": "hidden",
"ZFS_PROP_NBMAND": "off",
"ZFS_PROP_REFRESERVATION": "782188042016609776",
"ZFS_PROP_AVAILABLE": "22170421248",
"ZFS_PROP_COPIES": "5",
"ZFS_PROP_CANMOUNT": "on"
}
},
{
"name": "sql-pool/disk1",
"type": "VOLUME",
"properties": {
"ZFS_PROP_TYPE": "volume",
"ZFS_PROP_USED": "10855325696",
"ZFS_PROP_REFQUOTA": "10823401472",
"ZFS_PROP_COMPRESSRATIO": "1.00",
"ZFS_PROP_CREATETXG": "288",
"ZFS_PROP_READONLY": "off",
"ZFS_NUM_PROPS": "all",
"ZFS_PROP_COMPRESSION": "off",
"ZFS_PROP_RESERVATION": "0",
"ZFS_PROP_VOLBLOCKSIZE": "32768",
"ZFS_PROP_NUMCLONES": "1",
"ZFS_PROP_NAME": "sql-pool/disk1",
"ZFS_PROP_CHECKSUM": "on",
"ZFS_PROP_REFRESERVATION": "15236734049616883339",
"ZFS_PROP_AVAILABLE": "32993458176",
"ZFS_PROP_CREATION": "1565875111",
"ZFS_PROP_REFERENCED": "31924224",
"ZFS_PROP_VOLSIZE": "10737418240"
}
}
]
Also published on Medium.