Changeset 12938
- Timestamp:
- 10/02/10 19:00:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/ZipCache.java
r12643 r12938 42 42 import java.net.URL; 43 43 import java.net.URLConnection; 44 import java.text.Parse Exception;44 import java.text.ParsePosition; 45 45 import java.text.SimpleDateFormat; 46 46 import java.util.Date; 47 47 import java.util.HashMap; 48 import java.util.Locale; 48 49 import java.util.zip.ZipException; 49 50 import java.util.zip.ZipFile; … … 102 103 } 103 104 105 static final SimpleDateFormat ASCTIME 106 = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US); 107 static final SimpleDateFormat RFC_1036 108 = new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US); 104 109 static final SimpleDateFormat RFC_1123 105 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); 110 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); 111 106 112 107 113 synchronized public static ZipFile get(final URL url) { … … 161 167 String dateString = HttpHead.get(url, "Last-Modified"); 162 168 Date date = null; 163 try { 164 if (dateString == null) { 165 throw new ParseException("Failed to get HEAD for " + url, 0); 169 ParsePosition pos = new ParsePosition(0); 170 171 if (dateString != null) { 172 date = RFC_1123.parse(dateString, pos); 173 if (date == null) { 174 date = RFC_1036.parse(dateString, pos); 175 if (date == null) 176 date = ASCTIME.parse(dateString, pos); 166 177 } 167 date = RFC_1123.parse(dateString); 168 long current = date.getTime(); 169 if (current > entry.lastModified) { 170 entry = fetchURL(url, false); 171 zipCache.put(url, entry); 172 } 173 } catch (ParseException e) { 174 Debug.trace("Failed to parse HTTP Last-Modified field: " + e); 175 entry = fetchURL(url, false); 176 zipCache.put(url, entry); 177 } 178 } else { 178 } 179 180 if (date == null || date.getTime() > entry.lastModified) { 181 entry = fetchURL(url, false); 182 zipCache.put(url, entry); 183 } 184 if (date == null) { 185 if (dateString == null) 186 Debug.trace("Failed to retrieve request header: " 187 + url.toString()); 188 else 189 Debug.trace("Failed to parse Last-Modified date: " + 190 dateString); 191 } 192 193 } else { 179 194 entry = fetchURL(url, false); 180 195 zipCache.put(url, entry);
Note: See TracChangeset
for help on using the changeset viewer.