Re: How to avoid Expires: 1970 header with URIRequestTargetUrlCodingStrategy

2007-11-27 Thread Edvin Syse

No you don't have to hve the servlet response for that
Just check if the Response is a WebResponse
That already has the setHeader methods


Thank you so much, it worked perfectly :)

-- Edvin

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



Re: How to avoid Expires: 1970 header with URIRequestTargetUrlCodingStrategy

2007-11-27 Thread Johan Compagner
No you don't have to hve the servlet response for that
Just check if the Response is a WebResponse
That already has the setHeader methods

On Nov 27, 2007 9:13 PM, Edvin Syse <[EMAIL PROTECTED]> wrote:

> > hmm this way i have never seen it before :)
>
> Hehe.. I know it might be a bit unconventional, but I think I have a good
> reason for it. Since the application is "virtualhosted", the
> session holds a path to the "filearchive" for the current instance (set
> based on the http host of the request), and the /files url of the
> site should serve up the files in the current site's filearchive.
>
> > then overwrite the ResourceStreamRequestTargets:
> > *
> >
> > protected* *void* configure(*final* RequestCycle requestCycle,
> > *final*Response response,
> > *final* IResourceStream resourceStream)
> > and set some headers in the response and call super.
>
> To do that I think I need to get to the HttpServletResponse, right? How
> can I retrieve that from the Response object? It seems to be of type
> org.apache.wicket.protocol.http.BufferedWebResponse.
>
> -- Edvin
>
> -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: How to avoid Expires: 1970 header with URIRequestTargetUrlCodingStrategy

2007-11-27 Thread Edvin Syse

hmm this way i have never seen it before :)


Hehe.. I know it might be a bit unconventional, but I think I have a good reason for it. Since the application is "virtualhosted", the 
session holds a path to the "filearchive" for the current instance (set based on the http host of the request), and the /files url of the 
site should serve up the files in the current site's filearchive.



then overwrite the ResourceStreamRequestTargets:
*

protected* *void* configure(*final* RequestCycle requestCycle,
*final*Response response,
*final* IResourceStream resourceStream)
and set some headers in the response and call super.


To do that I think I need to get to the HttpServletResponse, right? How can I retrieve that from the Response object? It seems to be of type 
org.apache.wicket.protocol.http.BufferedWebResponse.


-- Edvin

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



Re: How to avoid Expires: 1970 header with URIRequestTargetUrlCodingStrategy

2007-11-27 Thread Johan Compagner
hmm this way i have never seen it before :)

But you could also do this with a mounted shared resource
But what you could do if you want to do it that way

then overwrite the ResourceStreamRequestTargets:
*

protected* *void* configure(*final* RequestCycle requestCycle,
*final*Response response,
*final* IResourceStream resourceStream)
and set some headers in the response and call super.

johan



On Nov 27, 2007 6:55 PM, Edvin Syse <[EMAIL PROTECTED]> wrote:

> 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]
>
>


How to avoid Expires: 1970 header with URIRequestTargetUrlCodingStrategy

2007-11-27 Thread Edvin Syse
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]