Skip to content

Commit

Permalink
Merge pull request #530 from iterate-ch/feature/response-propstat-status
Browse files Browse the repository at this point in the history
Return status from first propstat element when found.
  • Loading branch information
dkocher authored Jan 10, 2025
2 parents cfeefc2 + 7ee726b commit 0aca217
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/github/sardine/DavResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ public DavResource(Response response) throws URISyntaxException
*/
private int getStatusCode(Response response)
{
List<Propstat> 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())
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/github/sardine/FunctionalSardineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0aca217

Please sign in to comment.