if WebDAV request returns error code, throw exception

This commit is contained in:
Adrian Kuschelyagi Malacoda 2020-12-17 02:46:01 -06:00
parent be5b64789a
commit 33491e3904

View File

@ -6,6 +6,7 @@ import java.net.URI;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
import jodd.http.HttpRequest; import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import lombok.Data; import lombok.Data;
import net.monarchpass.piecannon.Server; import net.monarchpass.piecannon.Server;
@ -28,7 +29,11 @@ public class WebDavServer implements Server {
request.basicAuthentication(username, password); request.basicAuthentication(username, password);
} }
request.send(); final HttpResponse response = request.send();
if (response.statusCode() >= 400) {
throw new RuntimeException(response.statusCode() + ": " + response.statusPhrase());
}
return target; return target;
} catch (final IOException exception) { } catch (final IOException exception) {
throw new RuntimeException(exception); throw new RuntimeException(exception);