* EepGet:

- Fix format of last-modified header to use strictest RFC 822
  - Stop immediately if socket connection to proxy fails
  - Don't forget lastModified/etag headers after redirect
  - Note SocketTimeout API breakage for Syndie
This commit is contained in:
zzz
2013-01-12 18:12:35 +00:00
parent 41af00a7d6
commit ed12bcefdb
3 changed files with 49 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
* Moved from NewsFetcher
@ -13,7 +14,7 @@ public abstract class RFC822Date {
// SimpleDateFormat is not thread-safe, methods must be synchronized
private static final SimpleDateFormat OUTPUT_FORMAT = new SimpleDateFormat("d MMM yyyy HH:mm:ss z", Locale.US);
private static final SimpleDateFormat OUTPUT_FORMAT = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US);
/**
* http://jimyjoshi.com/blog/2007/08/rfc822dateparsinginjava.html
@ -22,7 +23,7 @@ public abstract class RFC822Date {
*/
private static final SimpleDateFormat rfc822DateFormats[] = new SimpleDateFormat[] {
OUTPUT_FORMAT,
new SimpleDateFormat("EEE, d MMM yy HH:mm:ss z", Locale.US),
new SimpleDateFormat("d MMM yy HH:mm:ss z", Locale.US),
new SimpleDateFormat("EEE, d MMM yy HH:mm z", Locale.US),
new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US),
new SimpleDateFormat("EEE, d MMM yyyy HH:mm z", Locale.US),
@ -31,6 +32,16 @@ public abstract class RFC822Date {
new SimpleDateFormat("d MMM yyyy HH:mm z", Locale.US)
};
//
// The router JVM is forced to UTC but do this just in case
//
static {
TimeZone utc = TimeZone.getTimeZone("GMT");
for (int i = 0; i < rfc822DateFormats.length; i++) {
rfc822DateFormats[i].setTimeZone(utc);
}
}
/**
* new Date(String foo) is deprecated, so let's do this the hard way
*
@ -56,4 +67,18 @@ public abstract class RFC822Date {
public synchronized static String to822Date(long t) {
return OUTPUT_FORMAT.format(new Date(t));
}
/****
public static void main(String[] args) {
if (args.length == 1) {
try {
System.out.println(to822Date(Long.parseLong(args[0])));
} catch (NumberFormatException nfe) {
System.out.println(nfe.toString());
}
} else {
System.out.println("Usage: RFC822Date numericDate");
}
}
****/
}