Changeset 12504
- Timestamp:
- 02/23/10 14:34:45 (12 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/ZipCache.java
r12451 r12504 33 33 package org.armedbear.lisp; 34 34 35 35 import org.armedbear.lisp.util.HttpHead; 36 36 import static org.armedbear.lisp.Lisp.*; 37 37 38 38 import java.io.File; 39 import java.io.InputStream;40 39 import java.io.IOException; 41 40 import java.net.JarURLConnection; … … 43 42 import java.net.URL; 44 43 import java.net.URLConnection; 45 import java.util.Enumeration; 44 import java.text.ParseException; 45 import java.text.SimpleDateFormat; 46 import java.util.Date; 46 47 import java.util.HashMap; 47 48 import java.util.zip.ZipException; 48 49 import java.util.zip.ZipFile; 49 import java.util.zip.ZipEntry;50 50 51 51 /** … … 68 68 // out, not allowing ZipFile.close() to succeed until that count 69 69 // has been reduced to 1 or the finalizer is executing. 70 // Unfortunately the relatively simple strategy of extend ed70 // Unfortunately the relatively simple strategy of extending 71 71 // ZipFile via a CachedZipFile does not work because there is not 72 72 // a null arg constructor for ZipFile. … … 101 101 return get(Pathname.makeURL(arg)); 102 102 } 103 104 static final SimpleDateFormat RFC_1123 105 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); 103 106 104 107 synchronized public static ZipFile get(final URL url) { … … 146 149 } 147 150 } 148 } else {151 } else if (url.getProtocol().equals("http")) { 149 152 // Unfortunately, the Apple JDK under OS X doesn't do 150 153 // HTTP HEAD requests, instead refetching the entire 151 // resource, so the following code is a waste. I assume 152 // this is the case in all Sun-dervied JVMs. We'll have 153 // to implement a custom HTTP lastModified checker. 154 155 // URLConnection connection; 156 // try { 157 // connection = url.openConnection(); 158 // } catch (IOException ex) { 159 // Debug.trace("Failed to open " 160 // + "'" + url + "'"); 161 // return null; 162 // } 163 // long current = connection.getLastModified(); 164 // if (current > entry.lastModified) { 165 // try { 166 // entry.file.close(); 167 // } catch (IOException ex) {} 168 // entry = fetchURL(url, false); 169 // } 154 // resource, and I assume this is the case in all 155 // Sun-derived JVMs. So, we use a custom HEAD 156 // implementation only looking for Last-Modified 157 // headers, which if we don't find, we give up and 158 // refetch the resource.n 159 String dateString = HttpHead.get(url, "Last-Modified"); 160 Date date = null; 161 try { 162 date = RFC_1123.parse(dateString); 163 long current = date.getTime(); 164 if (current > entry.lastModified) { 165 entry = fetchURL(url, false); 166 zipCache.put(url, entry); 167 } 168 } catch (ParseException e) { 169 Debug.trace("Failed to parse HTTP Last-Modified field: " + e); 170 entry = fetchURL(url, false); 171 zipCache.put(url, entry); 172 } 173 } else { 174 entry = fetchURL(url, false); 175 zipCache.put(url, entry); 170 176 } 171 177 } else {
Note: See TracChangeset
for help on using the changeset viewer.