You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2004/05/20 21:34:01 UTC
cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/http HttpFileObject.java
imario 2004/05/20 12:34:01
Modified: vfs/src/java/org/apache/commons/vfs/provider/http
HttpFileObject.java
Log:
add content-type and content-encoding to the file attributes
Revision Changes Path
1.6 +22 -1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java
Index: HttpFileObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- HttpFileObject.java 10 May 2004 20:09:49 -0000 1.5
+++ HttpFileObject.java 20 May 2004 19:34:01 -0000 1.6
@@ -16,6 +16,7 @@
package org.apache.commons.vfs.provider.http;
import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HeaderElement;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
@@ -30,6 +31,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.util.Map;
+import java.util.TreeMap;
/**
* A file object backed by commons httpclient.
@@ -184,5 +187,23 @@
{
method.releaseConnection();
}
+ }
+
+ protected Map doGetAttributes() throws Exception
+ {
+ TreeMap map = new TreeMap();
+
+ Header contentType = method.getResponseHeader("content-type");
+ if (contentType != null)
+ {
+ HeaderElement[] element = contentType.getValues();
+ if (element != null && element.length > 0)
+ {
+ map.put("content-type", element[0].getName());
+ }
+ }
+
+ map.put("content-encoding", method.getResponseCharSet());
+ return map;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org