f64df8332a2328c2fe6325dcd1cb0b9281586957
galt
  Thu Feb 10 01:55:48 2011 -0800
added alternate method for finding filesize via byterange, useful workaround for udc used against poorly configured remote apache servers
diff --git src/lib/udc.c src/lib/udc.c
index f477a38..3babab6 100644
--- src/lib/udc.c
+++ src/lib/udc.c
@@ -348,34 +348,42 @@
 return total;
 }
 
 boolean udcInfoViaHttp(char *url, struct udcRemoteFileInfo *retInfo)
 /* Gets size and last modified time of URL
  * and returns status of HEAD GET. */
 {
 verbose(2, "checking http remote info on %s\n", url);
 struct hash *hash = newHash(0);
 int status = netUrlHead(url, hash);
 if (status != 200) // && status != 302 && status != 301)
     return FALSE;
 char *sizeString = hashFindValUpperCase(hash, "Content-Length:");
 if (sizeString == NULL)
     {
+    /* try to get remote file size by an alternate method */
+    retInfo->size = netUrlSizeByRangeResponse(url);
+    if (retInfo->size < 0)
+	{
     hashFree(&hash);
     errAbort("No Content-Length: returned in header for %s, can't proceed, sorry", url);
     }
+    }
+else
+    {
 retInfo->size = atoll(sizeString);
+    }
 
 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: or Date: returned in header for %s, can't proceed, sorry", url);
 	}
     }
 struct tm tm;
 time_t t;