fix(http): keep snapshot names in one path segment and report odd server responses clearly (#54)

* fix(http): keep snapshot names in one path segment and report odd server responses clearly

Snapshot names are URL-encoded and names that would change the path are refused; every trailing slash is stripped from the endpoint; a non-JSON body or a redirect gets a message that says so instead of a parser error; requests use HTTP/1.1. snapshot delete reports a missing snapshot API like save and load, save warns that --message is not sent yet, and export/import no longer cite a server version that does not exist.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(http): tell a missing snapshot API from its status, not from the error text

The error message carries the request path, so a snapshot named nightly404 turned a real server error into 'not available'. FlociException now carries the HTTP status and the snapshot commands ask that.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-10 21:39:43 -05:00
1 parent 1a7e84cd23
commit 24b4280f69
10 files changed
+289 -22

No files matched your search

@@ -1,7 +1,29 @@
package io.floci.cli.http;
public class FlociException extends Exception {
private final int status;
public FlociException(String message) {
this(message, 0);
}
/** An error the server answered with HTTP {@code status}. */
public FlociException(String message, int status) {
super(message);
this.status = status;
}
/** The HTTP status the server answered with, or 0 when the failure was not an HTTP response. */
public int status() {
return status;
}
/**
* The server has no such endpoint (404) or does not implement it (501). Asked of the status,
* never of the message: the message carries the request path, and a path can contain "404".
*/
public boolean endpointMissing() {
return status == 404 || status == 501;
}
}