added fallback for util_parse_lastmodified, because some servers incorrectly use ISO-8601 dates for lastmodified - TODO: implement the ISO-8601 parsing

Tue, 13 Oct 2015 13:05:38 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 13 Oct 2015 13:05:38 +0200
changeset 158
33237261321e
parent 157
8dccc3063e28
child 159
7e0a8912ca25

added fallback for util_parse_lastmodified, because some servers incorrectly use ISO-8601 dates for lastmodified - TODO: implement the ISO-8601 parsing

libidav/utils.c file | annotate | diff | comparison | revisions
--- a/libidav/utils.c	Tue Oct 13 12:55:37 2015 +0200
+++ b/libidav/utils.c	Tue Oct 13 13:05:38 2015 +0200
@@ -58,20 +58,29 @@
 
 
 time_t util_parse_creationdate(char *str) {
+    // parse a ISO-8601 date
     // example: 2012-11-29T21:35:35Z
     if(!str) {
         return 0;
     }
-    // TODO
-    return 0;
+    // TODO: implement
+    return -1;
 }
 
 time_t util_parse_lastmodified(char *str) {
+    // parse a rfc-1123 date
     // example: Thu, 29 Nov 2012 21:35:35 GMT
     if(!str) {
         return 0;
     } else {
-        return curl_getdate(str, NULL);
+        time_t result = curl_getdate(str, NULL);
+        if(result == -1) {
+            // some shit server don't comply with the WebDAV standard and
+            // use ISO-8601 dates for lastmodified (e.g. Microsoft Sharepoint)
+            return util_parse_creationdate(str);
+        } else {
+            return result;
+        }
     }
 }
 

mercurial