In my WicketApplication class I have mounted a URL with the URIRequestTargetUrlCodingStrategy to serve files in my virtualhosted CMS-application written in Wicket 1.3. The problem with this is that it returns a header like this with the file it serves up:

  HTTP/1.1 200 OK
  Expires: Thu, 01 Jan 1970 00:00:00 GMT
  Set-Cookie: JSESSIONID=1ugsnhj1evodg;Path=/
  Content-Type: image/jpeg; charset=UTF-8
  Content-Length: 55925
  Connection: keep-alive
  Server: Jetty(6.1.5)

The Expires: header obviously prevents the client from caching the result. How 
can I override this header?

My implementation is like this:

mount(new URIRequestTargetUrlCodingStrategy("/files") {
        @Override
        public IRequestTarget decode(RequestParameters requestParameters) {
                // TODO: Better path-checking
                final String uri = getURI(requestParameters).replaceAll("\\.\\.", 
"");
                /* Redirect to / if empty result, maybe return 404 instead? */
                if ("".equals(uri))
                        return new RedirectRequestTarget("/");
                
                /* Get file for this instance */
                File file = new File(((TornadoWebSession) 
(Session.get())).getInstancePath() + File.separator + uri);
                return new ResourceStreamRequestTarget(new 
FileResourceStream(file));
        }
});

Sincerely,
Edvin Syse

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to