src/lib/net.c 1.65
1.65 2009/02/10 21:00:42 galt
cleaning up, udc stuff already moved by jim to udc.c
Index: src/lib/net.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/net.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -b -B -U 4 -r1.64 -r1.65
--- src/lib/net.c 7 Feb 2009 18:53:30 -0000 1.64
+++ src/lib/net.c 10 Feb 2009 21:00:42 -0000 1.65
@@ -933,106 +933,8 @@
return lf;
}
}
-#ifdef EXAMPLE_ONLY /* Real copy of this moved to udc.c */
-int udcDataViaHttp(char *url, bits64 offset, int size, void *buffer)
-/* Fetch a block of data of given size into buffer using the http: protocol.
- * Returns number of bytes actually read. Does an errAbort on
- * error. Typically will be called with size in the 8k - 64k range. */
-{
-char rangeUrl[1024];
-if (!startsWith("http://",url))
- {
- errAbort("Invalid protocol in url [%s] in udcDataViaHttp, only http supported", url);
- }
-safef(rangeUrl, sizeof(rangeUrl), "%s;byterange=%lld-%lld"
- , url
- , (long long) offset
- , (long long) offset + size - 1);
-int sd = netUrlOpen(rangeUrl);
-if (sd < 0)
- errAbort("Couldn't open %s", url); // do we really want errAbort here?
-
-char *newUrl = NULL;
-int newSd = 0;
-if (!netSkipHttpHeaderLinesHandlingRedirect(sd, url, &newSd, &newUrl))
- errAbort("Couldn't open %s", url); // do we really want errAbort here?
-
-if (newUrl) // not sure redirection will work with byte ranges as it is now
- {
- freeMem(newUrl);
- sd = newSd;
- }
-
-int rd = 0, total = 0, remaining = size;
-char *buf = (char *)buffer;
-while ((remaining > 0) && ((rd = read(sd, buf, remaining)) > 0))
- {
- total += rd;
- buf += rd;
- remaining -= rd;
- }
-if (rd == -1)
- errnoAbort("error reading socket");
-close(sd);
-
-return total;
-}
-
-int udcSizeTimeViaHttp(char *url, long long *pSize, time_t *pTime)
-/* Sets size and last modified time of URL
- * and returns status of HEAD GET. */
-{
-struct hash *hash = newHash(0);
-int status = netUrlHead(url, hash);
-if (status != 200) // && status != 302 && status != 301)
- {
- return status;
- }
-*pSize = atoll(hashMustFindVal(hash, "Content-Length:"));
-//Content-Length: 1677
-
-char *lastModString = hashMustFindVal(hash, "Last-Modified:");
-// Last-Modified: Wed, 25 Feb 2004 22:37:23 GMT
-// Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
-
-#include <time.h>
-
-struct tm tm;
-time_t t;
-
-// TODO: it's very likely that there are other date string patterns
-// out there that might be encountered.
-if (strptime(lastModString, "%a, %d %b %Y %H:%M:%S %Z", &tm) == NULL)
- { /* Handle error */;
- errAbort("unable to parse last-modified string [%s]", lastModString);
- }
-
-//printf("year: %d; month: %d; day: %d;\n",
-// tm.tm_year, tm.tm_mon, tm.tm_mday);
-//printf("hour: %d; minute: %d; second: %d\n",
-// tm.tm_hour, tm.tm_min, tm.tm_sec);
-//printf("week day: %d; year day: %d\n", tm.tm_wday, tm.tm_yday);
-
-
-tm.tm_isdst = -1; /* Not set by strptime(); tells mktime()
- to determine whether daylight saving time
- is in effect */
-t = mktime(&tm);
-if (t == -1)
- { /* Handle error */;
- errAbort("mktime failed while parsing last-modified string [%s]", lastModString);
- }
-
-//printf("seconds since the Epoch: %ld\n", (long) t);"
-
-*pTime = t;
-
-hashFree(&hash);
-return status;
-}
-#endif /* EXAMPLE_ONLY */
struct lineFile *netLineFileOpen(char *url)
/* Return a lineFile attached to url. This one
* will skip any headers. Free this with