From d4647139971f08a815e226825b743fd3fe784433 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 10 Jan 2025 09:57:56 +0100 Subject: [PATCH 1/2] Return status from first propstat element when found. --- src/main/java/com/github/sardine/DavResource.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/github/sardine/DavResource.java b/src/main/java/com/github/sardine/DavResource.java index fe40a710..154e0852 100644 --- a/src/main/java/com/github/sardine/DavResource.java +++ b/src/main/java/com/github/sardine/DavResource.java @@ -168,6 +168,18 @@ public DavResource(Response response) throws URISyntaxException */ private int getStatusCode(Response response) { + List list = response.getPropstat(); + for(Propstat propstat : list) { + if(propstat.getStatus() != null) { + try { + return BasicLineParser.parseStatusLine(propstat.getStatus(), null).getStatusCode(); + } + catch(ParseException e) { + log.warning(String.format("Failed to parse status line: %s", propstat.getStatus())); + return -1; + } + } + } String status = response.getStatus(); if (status == null || status.isEmpty()) { From 7ee726b63d200ff0bc0139e21a51afc727f57b62 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 10 Jan 2025 10:09:51 +0100 Subject: [PATCH 2/2] Adjust test with 404 status. --- src/test/java/com/github/sardine/FunctionalSardineTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/com/github/sardine/FunctionalSardineTest.java b/src/test/java/com/github/sardine/FunctionalSardineTest.java index ab522cd7..bc3e6054 100644 --- a/src/test/java/com/github/sardine/FunctionalSardineTest.java +++ b/src/test/java/com/github/sardine/FunctionalSardineTest.java @@ -226,8 +226,7 @@ public void getDavQuota() throws IOException Sardine sardine = SardineFactory.begin(); sardine.createDirectory(url); DavQuota davQuota = sardine.getQuota(url); - assertTrue(davQuota.getQuotaAvailableBytes() > 0); - assertEquals(0, davQuota.getQuotaUsedBytes()); + assertNull(davQuota); } @Test(expected = SardineException.class)