You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Guillaume Smet <gu...@gmail.com> on 2011/12/19 11:59:29 UTC

PackageResource and content type

Hello,

In a Resource extending PackageResource (a LessCSS implementation), we
set the content type on the ResourceStream to text/css.

The problem is that PackageResource overrides it in
newResourceResponse (starting from line 255 in 1.5.3):
                        final String contentType;
			if (Application.exists())
			{
				contentType = Application.get().getMimeType(path);
			}
			else
			{
				contentType = resourceStream.getContentType();
			}

If not null, shouldn't we give the resourceStream's content type a
higher priority and use Application.get().getMimeType(path) only if it
is null?

IMHO we should probably have something like that:
final String contentType = resourceStream.getContentType();
if (contentType == null && Application.exists())
{
	contentType = Application.get().getMimeType(path);
}

Thanks for your feedback.

-- 
Guillaume

Re: PackageResource and content type

Posted by Guillaume Smet <gu...@gmail.com>.
On Mon, Dec 19, 2011 at 12:03 PM, Martin Grigorov <mg...@apache.org> wrote:
> Agree.
> File a ticket.
> Thanks!

Done: https://issues.apache.org/jira/browse/WICKET-4306

-- 
Guillaume

Re: PackageResource and content type

Posted by Martin Grigorov <mg...@apache.org>.
Agree.
File a ticket.
Thanks!

On Mon, Dec 19, 2011 at 12:59 PM, Guillaume Smet
<gu...@gmail.com> wrote:
> Hello,
>
> In a Resource extending PackageResource (a LessCSS implementation), we
> set the content type on the ResourceStream to text/css.
>
> The problem is that PackageResource overrides it in
> newResourceResponse (starting from line 255 in 1.5.3):
>                        final String contentType;
>                        if (Application.exists())
>                        {
>                                contentType = Application.get().getMimeType(path);
>                        }
>                        else
>                        {
>                                contentType = resourceStream.getContentType();
>                        }
>
> If not null, shouldn't we give the resourceStream's content type a
> higher priority and use Application.get().getMimeType(path) only if it
> is null?
>
> IMHO we should probably have something like that:
> final String contentType = resourceStream.getContentType();
> if (contentType == null && Application.exists())
> {
>        contentType = Application.get().getMimeType(path);
> }
>
> Thanks for your feedback.
>
> --
> Guillaume



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com