Please note my comments below.
The "private static final String[] DATE_PATTERNS" might be more efficiently
declared as an array of DateFormat instances (never publicly accessible, as
that could be tampered with using the "apply" method for example), as that
avoids repeat parsing of the date format pattern.
Unfortunately SimpleDateFormat is not thread safe. This means that we cannot rely on a static set of DateFormat instances. Take a look at the synchronization section in http://java.sun.com/j2se/1.4.1/docs/api/java/text/SimpleDateFormat.html.
Other comment: it might be worth implementing a "getLastModified" method in
HttpMethodBase (or even declaring it in the HttpMethod interface) so that
common functionality (common with java.net.HttpURLConnection) can be
provided. This would simply parse the value of the "Last-Modified" response
header (if present) by delegating to this method.
Though a method does not explicitly exist for getting the last modified header it can be retrieved using HttpMethod.getResponseHeader("Last-Modified"). Adding a method getLastModified() is not an option for 2.0 as we cannot change the API for HttpMethod at this point. Please feel free to add a Bugzilla enhancement request for a later release.
Going further, it might be worth providing a method in DateParser that uses
the "java.text.DateFormat.format(java.util.Date)" method to format request
headers ("public static String DateParse.toDateHeader(Date)" ?), such as
If-Modified-Since, and even implementing convenience methods on some Method
implementations to apply the appropriate headers that translates
"java.util.Date" objects or "long" values into a date header.
Agreed, this would be handy. Currently this can be accomplished with the following:
SimpleDateFormat format = new SimpleDateFormat(DateParser.PATTERN_RFC1123);
String formattedDate = format.format(someDate);
In general I think it would be nice for HttpClient to have more tools for handling headers. One option would be to add a bunch of methods to HttpMethod, but I think this would add too much clutter. Perhaps we should have a "HeaderUtil" class with convenience methods for parsing, formatting, etc. Thoughts?
Mike
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
