wro4j icon indicating copy to clipboard operation
wro4j copied to clipboard

DispatcherStreamLocator erroneously computes servletContextPath

Open andredasilvapinto opened this issue 12 years ago • 2 comments

https://github.com/alexo/wro4j/blob/1.7.x/wro4j-core/src/main/java/ro/isdc/wro/model/resource/locator/support/DispatcherStreamLocator.java#L106

is not a valid way to compute the servletContextPath.

Consider: Request url: http://foo.bar:80/resources/some.css Servlet path: "" Location: /some_other.css

The resulting request will be made to http://foo.bar:80/resources/some.css/some_other.css which is obviously wrong.

Alternatively the servletContextPath can be computed by using something like:

request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();

I'm also not sure https://github.com/alexo/wro4j/blob/1.7.x/wro4j-core/src/main/java/ro/isdc/wro/model/resource/locator/support/DispatcherStreamLocator.java#L92 is the best way to identify errors with the dispatcher location. A valid resource can simply be empty.

andredasilvapinto avatar Nov 21 '13 23:11 andredasilvapinto

Thanks for reporting this.

Regarding empty resources, don't you agree that inncluding an empty resource is an exceptional use case?

alexo avatar Nov 22 '13 05:11 alexo

It's not very common, I agree. But it may happen (it actually did in our project). I think conceptually "not found" and "empty" should be treated differently, but it is not that bad I guess.

andredasilvapinto avatar Nov 22 '13 10:11 andredasilvapinto