Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 91237 invoked from network); 4 Sep 2007 01:07:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2007 01:07:22 -0000 Received: (qmail 46719 invoked by uid 500); 4 Sep 2007 01:07:16 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 46697 invoked by uid 500); 4 Sep 2007 01:07:16 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 46688 invoked by uid 99); 4 Sep 2007 01:07:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2007 18:07:16 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 01:08:32 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E1656714163 for ; Mon, 3 Sep 2007 18:06:57 -0700 (PDT) Message-ID: <25107746.1188868017903.JavaMail.jira@brutus> Date: Mon, 3 Sep 2007 18:06:57 -0700 (PDT) From: "Vasily Zakharov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Reopened: (HARMONY-4699) [classlib][luni] URLConnection.getContentType() works with files incorrectly In-Reply-To: <6047120.1188509790557.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-4699?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vasily Zakharov reopened HARMONY-4699: -------------------------------------- I've attached a regression test patch. Tim, could you please apply it as well? Thank you! > [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: Harmony-4699-Test.patch, 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.