You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2007/08/31 16:52:32 UTC
[jira] Reopened: (HARMONY-4699) [classlib][luni]
URLConnection.getContentType() works with files incorrectly
[ https://issues.apache.org/jira/browse/HARMONY-4699?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vasily Zakharov reopened HARMONY-4699:
--------------------------------------
> [classlib][luni] URLConnection.getContentType() works with files incorrectly
> ----------------------------------------------------------------------------
>
> Key: HARMONY-4699
> URL: https://issues.apache.org/jira/browse/HARMONY-4699
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Vasily Zakharov
> Assignee: Tim Ellison
> Attachments: Test.zip
>
>
> In Harmony implementation, java.net.URLConnection.getContentType() works incorrectly when addresses a file URL:
> 1. For files with .rtf extension, RI returns "application/rtf", while Harmony returns "text/rtf".
> 2. For files with .java extension, RI returns "text/plain", while Harmony returns "content/unknown".
> 3. For files with .doc extension, RI returns "content/unknown", while Harmony returns "application/msword". The same is true for other known extensions.
> 4. For files with unrecognized extension and with HTML content, RI returns "text/html", while Harmony returns "content/unknown".
> 5. For directories, RI returns "text/plain", while Harmony returns "text/html".
> Items 1 and 2 look like a minor issues that would better be fixed for compatibility with RI.
> Item 3 looks like a non-bug difference, as Harmony behaves clearly better than RI in these cases.
> Item 4 looks like a serious bug, as RI clearly looks into file content for the file type, and Harmony does not. Looks like org.apache.harmony.luni.internal.net.www.protocol.file.FileURLConnection.getContentType() needs to be fixed to use guessContentTypeFromStream() in addition to guessContentTypeFromName().
> Item 5 looks like an important compatibility issue that is better be fixed.
> The attached archive contains the reproducer with some test files it uses. Here's the reproducer code:
> public class Test {
> static void printContentType(String fileName) throws java.io.IOException {
> System.out.println(fileName + ": " + new java.net.URL("file:" + fileName).openConnection().getContentType());
> }
> public static void main(String argv[]) {
> try {
> printContentType("test.rtf");
> printContentType("Test.java");
> printContentType("test.doc");
> printContentType("test.htx");
> printContentType(".");
> } catch (Exception e) {
> e.printStackTrace(System.out);
> }
> }
> }
> Output on RI:
> test.rtf: application/rtf
> Test.java: text/plain
> test.doc: content/unknown
> test.htx: text/html
> .: text/plain
> Output on Harmony:
> test.rtf: text/rtf
> Test.java: content/unknown
> test.doc: application/msword
> test.htx: content/unknown
> .: text/html
> This issue is a blocker for HARMONY-4696, as JEditorPane.getContentType() should be based on URLConnection.getContentType() that now works incorrectly.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.