This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: getting the JDK built-in web server to set the correct mime type
- From: alex mitchell <lexaay at gmail dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: "kawa at sourceware dot org" <kawa at sourceware dot org>
- Date: Thu, 02 May 2013 16:59:31 +0800
- Subject: Re: getting the JDK built-in web server to set the correct mime type
Hi Per,
Thanks. However, I tried the patch, and it only sets the mime type for
text/html. For other file types, such as .js or .css, the mime type still
isn't set. I think what is happening is that absPath is an instance of
URLPath, not FilePath, so the code:
if (absPath instanceof FilePath) {
contentType = Files.probeContentType
(((FilePath) absPath).toNPath());
}
is never entered.
Then the subsequent call to URLConnection.guessContentTypeFromName(path)
seems to recognize very few mime types, returning null for almost
everything. I found that javax.activation.MimetypesFileTypeMap seems to
work better, since it allows for additional mime types to be specified,
but there may be a good reason for not using this.
This is not an urgent fix, as the lack of mime types only seems to impact
internet explorer, but it would be nice to have this working. Thanks again
for your help.
Alex
On 13-05-02 3:16 AM, "Per Bothner" <per@bothner.com> wrote:
>On 05/01/2013 01:10 AM, Per Bothner wrote:
>> I found a webpage suggesting using
>> java.nio.file.Files.html#probeContentType
>> This does require Java 7.
>>
>> I'll explore more later.
>
>Attached is a possible patch.
>--
> --Per Bothner
>per@bothner.com http://per.bothner.com/