You are right.
It tries with getHeaderName(String) which looks in MimeTable and falls back
to by stream.
I think you need to set the type in your mailcap file.


On Tue, Jul 30, 2013 at 8:16 PM, Chris Snyder <[email protected]>wrote:

> Except that URLConnection#getContentType doesn't even use MimeTable:
>
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/sun/net/www/URLConnection.java?av=f#147
>
> URLConnection#guessContentTypeFromStream is what it's using:
>
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/net/URLConnection.java#URLConnection.guessContentTypeFromStream%28java.io.InputStream%29
> Ugh - what a mess. That seems like a very arbitrary set of filetypes to
> test for (FlashPix?). It sees that the SVG file starts with <?xml…, so it
> returns application/xml - not wrong, per se - but not accurate enough.
>
> > On my
> > machine
> System.err.println(URLConnection.getFileNameMap().getContentTypeFor("file.svg"));
> > prints null
> Same here. However, the following returns "application/xml" (test.svg must
> be an SVG file, of course):
>
> System.err.println(URLConnection.guessContentTypeFromStream(getClass().getResourceAsStream("test.svg")));
>
> Thanks,
> Chris
> --
> Chris Snyder
> Web Developer, BioLogos
> 616.328.5208 x203
> biologos.org
>
> On Jul 30, 2013, at 13:52, Martin Grigorov <[email protected]> wrote:
>
> > This is nasty indeed!
> >
> > According to
> >
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/sun/net/www/MimeTable.java#MimeTable
> > the
> > mime types are loaded from mailcap files.
> > See "man update-mime"
> >
> >
> > On Tue, Jul 30, 2013 at 7:40 PM, Chris Snyder <[email protected]
> >wrote:
> >
> >> However, just above that (line 122) it gets the contentType from the
> >> URLConnection, which returns "application/xml". Since
> >> streamData.contentType is not null, it never gets to line 126.
> >>
> >> Thanks so much for your help!
> >>
> >> -Chris
> >> --
> >> Chris Snyder
> >> Web Developer, BioLogos
> >> 616.328.5208 x203
> >> biologos.org
> >>
> >> On Jul 30, 2013, at 13:30, Martin Grigorov <[email protected]>
> wrote:
> >>
> >>> Hi,
> >>>
> >>> According to
> >>>
> >>
> https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/resource/UrlResourceStream.java?source=cc#L126
> >>> if
> >>> theere is an application then it should be used before falling back.
> >>
> >>
>
>

Reply via email to