Index: URLConnection.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/URLConnection.java,v retrieving revision 1.29 diff -u -r1.29 URLConnection.java --- URLConnection.java 22 Jul 2004 01:34:55 -0000 1.29 +++ URLConnection.java 5 Aug 2004 00:17:24 -0000 @@ -37,6 +37,8 @@ package java.net; +import gnu.java.net.content.GenericHandler; + import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -414,13 +416,13 @@ * This class first determines the MIME type of the content, then creates * a ContentHandler object to process the input. If the ContentHandlerFactory * is set, then that object is called to load a content handler, otherwise - * a class called gnu.java.net.content.<content_type> is tried. - * The default class will also be used if the content handler factory returns - * a null content handler. + * a class called gnu.java.net.content.<content_type> is tried. If this + * handler does not exist, it will fall back on the + * gnu.java.net.content.GenericHandler which simply wraps the data in an + * InputStream. The content_type specific check and subsequent fall back is + * done if the content handler factory returns null as well. * * @exception IOException If an error occurs - * @exception UnknownServiceException If the protocol does not support the - * content type */ public Object getContent() throws IOException { @@ -439,16 +441,23 @@ // Then try our default class try { - Class cls = - Class.forName("gnu.java.net.content." + type.replace('/', '.')); - Object obj = cls.newInstance(); + String typeClass = type.replace('/', '.'); - if (! (obj instanceof ContentHandler)) - throw new UnknownServiceException(type); + // deal with "Content-Type: text/html; charset=ISO-8859-1" + int parameterBegin = typeClass.indexOf(';'); + if (parameterBegin >= 1) + typeClass = typeClass.substring(0, parameterBegin); + Class cls = Class.forName("gnu.java.net.content." + + typeClass); - ch = (ContentHandler) obj; - return ch.getContent(this); + Object obj = cls.newInstance(); + + if (obj instanceof ContentHandler) + { + ch = (ContentHandler) obj; + return ch.getContent(this); + } } catch (ClassNotFoundException e) { @@ -460,7 +469,8 @@ { } - throw new UnknownServiceException(type); + GenericHandler handler = new GenericHandler(); + return handler.getContent(this); } /**