Author: markt
Date: Thu May 29 14:32:02 2008
New Revision: 661488
URL: http://svn.apache.org/viewvc?rev=661488&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45101
Format dates for header value from DirContextURLConnection using HTTP format.
Patch provided by Chris Hubick.
Modified:
tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
Modified:
tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java?rev=661488&r1=661487&r2=661488&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
(original)
+++ tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
Thu May 29 14:32:02 2008
@@ -39,6 +39,7 @@
import org.apache.naming.JndiPermission;
import org.apache.naming.resources.Resource;
import org.apache.naming.resources.ResourceAttributes;
+import org.apache.tomcat.util.http.FastHttpDateFormat;
/**
* Connection to a JNDI directory context.
@@ -222,6 +223,18 @@
}
+ protected String getHeaderValueAsString(Object headerValue) {
+ if (headerValue == null) return null;
+ if (headerValue instanceof Date) {
+ // return date strings (ie Last-Modified) in HTTP format, rather
+ // than Java format
+ return FastHttpDateFormat.formatDate(
+ ((Date)headerValue).getTime(), null);
+ }
+ return headerValue.toString();
+ }
+
+
/**
* Returns an unmodifiable Map of the header fields.
*/
@@ -248,7 +261,8 @@
ArrayList attributeValueList = new ArrayList(attribute.size());
NamingEnumeration attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
- attributeValueList.add(attributeValues.next().toString());
+ Object attrValue = attributeValues.next();
+ attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if
attribute.size() didn't lie
headerFields.put(attributeID,
Collections.unmodifiableList(attributeValueList));
@@ -285,7 +299,8 @@
if (attributeID.equalsIgnoreCase(name)) {
Attribute attribute = attributes.get(attributeID);
if (attribute == null) return null;
- return attribute.get(attribute.size()-1).toString();
+ Object attrValue = attribute.get(attribute.size()-1);
+ return getHeaderValueAsString(attrValue);
}
}
} catch (NamingException ne) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]