This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]