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.


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

> Hi Martin,
>
> Thanks for the extremely prompt response. Unfortunately, it appears that
> Application#getMimeType isn't called for UrlResourceStream resources -
> UrlResourceStream#getData calls URLConnection#getContentType, at which
> point we've entrusted the mime-type to Java.
>
> Versions I should have included in my first email: I'm using Wicket 6.9.1,
> using the Jetty server referenced in the quickstart.
>
> Thanks,
> Chris
> --
> Chris Snyder
> Web Developer, BioLogos
> 616.328.5208 x203
> biologos.org
>
> On Jul 30, 2013, at 13:06, Martin Grigorov <[email protected]> wrote:
>
> > Hi,
> >
> > You can override org.apache.wicket.Application#getMimeType
> >
> >
> > On Tue, Jul 30, 2013 at 7:01 PM, Chris Snyder <[email protected]
> >wrote:
> >
> >> I'm trying to serve SVG images as package resources. However, when I do
> >> so, the image files are served with a mime-type of application/xml,
> rather
> >> than the correct image/svg+xml. This causes strange behavior in Google
> >> Chrome - the image displays as a broken link when included in an <img/>
> >> tag, but renders fine when the image URL is opened directly. If the
> >> resource is served from the main webapp directory rather than as a
> package
> >> resource, the correct mime-type is sent and Chrome displays the image
> >> properly.
> >>
> >> Delving into the code, it appears that the problem is Java's
> >> URLConnection.guessContentTypeFromStream() method, which doesn't support
> >> SVG files. I've verified this problem on both the Apple-supplied Java
> 1.6
> >> and the official Oracle Java 1.7, both on MacOS X.
> >>
> >> What would be the best way to work around this issue? I tried creating
> my
> >> own custom PackageResource wrapper, which had its own
> PackageResourceStream
> >> wrapper, but it quickly got unwieldy (as well as being a nightmare for
> >> future maintainability).
> >>
> >> My goal is to have a subclass of Image that returns either a reference
> to
> >> an SVG or a PNG depending on the browser version. I first noticed the
> >> mime-type problem with my subclass, but I verified that it also exists
> when
> >> using the standard Image class.
> >>
> >> Thanks in advance for your help!
> >> -Chris Snyder
> >> --
> >> Chris Snyder
> >> Web Developer, BioLogos
> >> 616.328.5208 x203
> >> biologos.org
> >>
> >>
>
>

Reply via email to