src/lib/udc.c 1.25

1.25 2009/11/10 23:23:59 angie
Force keys to uppercase for netUrlHead's hash, for case-insensitive lookup. Also, in udcInfoViaHttp, accept Date: as a poor substitute for missing Last-Modified:.
Index: src/lib/udc.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/udc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -b -B -U 4 -r1.24 -r1.25
--- src/lib/udc.c	6 Nov 2009 22:42:06 -0000	1.24
+++ src/lib/udc.c	10 Nov 2009 23:23:59 -0000	1.25
@@ -263,21 +263,27 @@
 struct hash *hash = newHash(0);
 int status = netUrlHead(url, hash);
 if (status != 200) // && status != 302 && status != 301)
     return FALSE;
-char *sizeString = hashFindVal(hash, "Content-Length:");
+char *sizeString = hashFindValUpperCase(hash, "Content-Length:");
 if (sizeString == NULL)
     {
     hashFree(&hash);
     errAbort("No Content-Length: returned in header for %s, can't proceed, sorry", url);
     }
 retInfo->size = atoll(sizeString);
 
-char *lastModString = hashFindVal(hash, "Last-Modified:");
+char *lastModString = hashFindValUpperCase(hash, "Last-Modified:");
 if (lastModString == NULL)
     {
+    // Date is a poor substitute!  It will always appear that the cache is stale.
+    // But at least we can read files from dropbox.com.
+    lastModString = hashFindValUpperCase(hash, "Date:");
+    if (lastModString == NULL)
+	{
     hashFree(&hash);
-    errAbort("No Last-Modified: returned in header for %s, can't proceed, sorry", url);
+	errAbort("No Last-Modified: or Date: returned in header for %s, can't proceed, sorry", url);
+	}
     }
 
 // Last-Modified: Wed, 25 Feb 2004 22:37:23 GMT
 // Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT