Index: src/test/java/org/apache/tika/mime/TestMimeUtils.java
===================================================================
--- src/test/java/org/apache/tika/mime/TestMimeUtils.java	(revision 585898)
+++ src/test/java/org/apache/tika/mime/TestMimeUtils.java	(working copy)
@@ -18,14 +18,15 @@
 package org.apache.tika.mime;
 
 //JDK imports
+
+
 import java.io.File;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 
-//Tika imports
 import org.apache.tika.metadata.TikaMimeKeys;
 
-//Junit imports
 import junit.framework.TestCase;
 
 /**
@@ -61,6 +62,10 @@
         assertNotNull(utils.getRepository().forName("text/x-tex"));
     }
 
+
+    /**
+     * Tests MIME type determination based solely on the URL's extension.
+     */
     public void testGuessMimeTypes() {
 
         assertEquals("application/pdf", utils.getRepository().getMimeType(
@@ -93,4 +98,40 @@
                 .getMimeType("x.xyz").getName());
     }
 
+
+    /**
+     * Tests MimeUtils.getMimeType(URL), which examines both the byte header
+     * and, if necessary, the URL's extension.
+     */
+    public void testMimeDeterminationForTestDocuments() {
+
+        assertEquals("text/html", getMimeType("testHTML.html"));
+        assertEquals("application/zip", getMimeType("test-documents.zip"));
+        assertEquals("application/vnd.ms-excel", getMimeType("testEXCEL.xls"));
+        assertEquals("text/html", getMimeType("testHTML_utf8.html"));
+        assertEquals("application/vnd.oasis.opendocument.text",
+                getMimeType("testOpenOffice2.odt"));
+        assertEquals("application/pdf", getMimeType("testPDF.pdf"));
+        assertEquals("application/vnd.ms-powerpoint", getMimeType("testPPT.ppt"));
+        assertEquals("application/rtf", getMimeType("testRTF.rtf"));
+        assertEquals("text/plain", getMimeType("testTXT.txt"));
+        assertEquals("application/msword", getMimeType("testWORD.doc"));
+        assertEquals("application/xml", getMimeType("testXML.xml"));
+    }
+
+    private String getMimeType(String filename) {
+
+        String type = null;
+
+        try {
+            URL url = getClass().getResource("/test-documents/" + filename);
+            type = utils.getType(url);
+        } catch (MalformedURLException e) {
+            fail(e.getMessage());
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
+
+        return type;
+    }
 }
Index: src/main/java/org/apache/tika/mime/MimeUtils.java
===================================================================
--- src/main/java/org/apache/tika/mime/MimeUtils.java	(revision 585898)
+++ src/main/java/org/apache/tika/mime/MimeUtils.java	(working copy)
@@ -17,17 +17,21 @@
 package org.apache.tika.mime;
 
 // JDK imports
+
+
 import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tika.metadata.TikaMimeKeys;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
-// Tika imports
-import org.apache.tika.metadata.TikaMimeKeys;
-
 /**
  * 
  * Wrapper external interface around a {@link MimeTypes} repository.
@@ -80,6 +84,26 @@
         return typeName;
     }
 
+
+    /**
+     * Determines the MIME type of the resource pointed to by the specified URL.
+     * Examines the file's header, and if it cannot determine the MIME type
+     * from the header, guesses the MIME type from the URL extension
+     * (e.g. "pdf).
+     *
+     * @param url
+     * @return
+     * @throws IOException
+     */
+    public String getType(URL url) throws IOException {
+        InputStream stream = url.openStream();
+        try {
+            return getType(null, url.toString(), getHeader(stream));
+        } finally {
+            stream.close();
+        }
+    }
+
     private final MimeTypes load(String tikaMimeFile) {
         LOG.info("Loading [" + tikaMimeFile + "]");
         Document document = getDocumentRoot(MimeUtils.class.getClassLoader()
@@ -111,4 +135,23 @@
         return document;
     }
 
+
+    /**
+     * Read the resource's header for determination of the MIME type.
+     */
+    private byte[] getHeader(InputStream stream) throws IOException {
+        byte[] bytes = new byte[repository.getMinLength()];
+        int totalRead = 0;
+        int lastRead = stream.read(bytes);
+        while (lastRead != -1) {
+            totalRead += lastRead;
+            if (totalRead == bytes.length) {
+                return bytes;
+            }
+            lastRead = stream.read(bytes, totalRead, bytes.length - totalRead);
+        }
+        byte[] shorter = new byte[totalRead];
+        System.arraycopy(bytes, 0, shorter, 0, totalRead);
+        return shorter;
+    }
 }
