aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorAnthony Green <green@gcc.gnu.org>2000-02-21 05:54:29 +0000
committerAnthony Green <green@gcc.gnu.org>2000-02-21 05:54:29 +0000
commit06440a12a2aba035710fe478b88f6224d77b5815 (patch)
tree5348c0d2f6947295be47163fd566b9b5264a8749 /libjava/java
parent38b3a2c089296350450e5dc0db2c279529fa6909 (diff)
downloadgcc-06440a12a2aba035710fe478b88f6224d77b5815.zip
gcc-06440a12a2aba035710fe478b88f6224d77b5815.tar.gz
gcc-06440a12a2aba035710fe478b88f6224d77b5815.tar.bz2
Makefile.in: Rebuilt.
* Makefile.in: Rebuilt. * Makefile.am (ordinary_java_source_files): Add gnu/gcj/io/DefaultMimeTypes.java and gnu/gcj/io/MimeTypes.java * scripts/MakeDefaultMimeTypes.java: New file. * scripts/mime.types: New file. * scripts/classes.pl: Moved from top level. * classes.pl: Moved to scripts directory. * java/net/URLConnection.java: Implement guessContentTypeFromName. * gnu/gcj/io/MimeTypes.java: New file. * gnu/gcj/io/DefaultMimeTypes.java: New file. From-SVN: r32086
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/net/URLConnection.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java
index 79547ee..a9b42e9 100644
--- a/libjava/java/net/URLConnection.java
+++ b/libjava/java/net/URLConnection.java
@@ -18,6 +18,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.Hashtable;
import java.util.StringTokenizer;
+import gnu.gcj.io.MimeTypes;
/**
* @author Warren Levy <warrenl@cygnus.com>
@@ -27,7 +28,7 @@ import java.util.StringTokenizer;
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Two guessContentTypeFrom... methods not implemented.
+ * Status: One guessContentTypeFrom... methods not implemented.
* getContent method assumes content type from response; see comment there.
*/
@@ -312,9 +313,25 @@ public abstract class URLConnection
factory = fac;
}
-// TODO: protected static String guessContentTypeFromName(String fname)
-// {
-// }
+ protected static String guessContentTypeFromName(String fname)
+ {
+ int dot = fname.lastIndexOf (".");
+
+ if (dot != -1)
+ {
+ if (dot == fname.length())
+ return ("application/octet-stream");
+ else
+ fname = fname.substring (dot + 1);
+ }
+
+ String type = MimeTypes.getMimeTypeFromExtension (fname);
+
+ if (type == null)
+ return("application/octet-stream");
+
+ return(type);
+ }
// TODO: public static String guessContentTypeFromStream(InputStream is)
// throws IOException