User: starksm
Date: 01/06/18 20:34:57
Modified: src/main/org/jboss/web Tag: Branch_2_4 WebServer.java
Log:
Fixed extraction of mime-type from file extension in getMimeType
Revision Changes Path
No revision
No revision
1.5.4.1 +20 -9 jboss/src/main/org/jboss/web/WebServer.java
Index: WebServer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/web/WebServer.java,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -u -r1.5 -r1.5.4.1
--- WebServer.java 2001/06/09 19:33:39 1.5
+++ WebServer.java 2001/06/19 03:34:57 1.5.4.1
@@ -32,9 +32,13 @@
*
* @see WebClassLoader
*
- * @author $Author: starksm $
- * @author [EMAIL PROTECTED]
- * @version $Revision: 1.5 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
+ * @version $Revision: 1.5.4.1 $
+ *
+ * Revisions:
+ *
+ * 20010618 scott.stark: Fixed extraction of mime-type from file extension in
getMimeType
*/
public class WebServer
implements Runnable
@@ -49,7 +53,7 @@
/** The web server http listening socket */
private ServerSocket server = null;
- /** The class wide mapping of type suffixes(.class, .txt) to their mime
+ /** The class wide mapping of type suffixes(class, txt) to their mime
type string used as the Content-Type header for the vended classes/resources */
private static Properties mimeTypes = new Properties();
/** The thread pool used to manage listening threads */
@@ -71,7 +75,8 @@
}
/** Augment the type suffix to mime type mappings
- @param extension, the type extension(.class, .txt)
+ @param extension, the type extension without a
+ period(class, txt)
@param type, the mime type string
*/
public void addMimeType(String extension, String type)
@@ -355,11 +360,17 @@
protected String getMimeType(String path)
{
int dot = path.lastIndexOf(".");
- String suffix = path.substring(dot);
- String type = mimeTypes.getProperty(suffix);
- if (type == null)
- type = "text/html";
+ String type = "text/html";
+ if( dot >= 0 )
+ {
+ // The suffix is the type extension without the '.'
+ String suffix = path.substring(dot+1);
+ String mimeType = mimeTypes.getProperty(suffix);
+ if( mimeType != null )
+ type = mimeType;
+ }
return type;
}
}
+
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development