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()) { 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)