You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Jean-Baptiste Quenot <jb...@apache.org> on 2007/04/15 13:25:13 UTC
Re: WebExternalResourceStream (Was: svn commit: r528885 - /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/WebExternalResourceStream.java)
* Johan Compagner:
> how is this class (WebExternalResourceStream.java) different to:
> UrlResourceStream ??
* UrlResourceStream implements IResource for URLs, uses URL.openConnection()
* WebExternalResourceStream implements IResource for a webapp URI,
uses the servlet context
> and how is WebExternalResourceRequestTarget different to
> ResourceStreamRequestTarget ?
The former could be dropped, except that currently
WebExternalResourceRequestTarget does not set Content-Length. If
we use WebExternalResource + ResourceStreamRequestTarget it will
throw an exception because length() is not implemented. I need to
address that, but that means I need to buffer the resource in a
ByteArrayOutputStream.
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/
Re: WebExternalResourceStream (Was: svn commit: r528885 - /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/WebExternalResourceStream.java)
Posted by Jean-Baptiste Quenot <jb...@apache.org>.
* Jean-Baptiste Quenot:
> * Johan Compagner:
> >
> > Which one should be dropped? The ResourceStreaMRequestTarget?
> > That will break all kinds of things. Then just adapt it the way you want.
>
> Don't take "drop" literally, I mean make
> WebExternalResourceRequestTarget reuse the
> WebExternalResourceStream.
Done. WebExternalResourceRequestTarget now directly uses
ResourceStreamRequestTarget#ResourceStreamRequestTarget(WebExternalResourceStream)
> I could change the implementation
> indeed to implement buffering. But in the end, we'll end up with
> many classes implementing buffering just for satisfying length().
I changed ResourceStreamRequestTarget to allow
IResourceStream.length() to return -1, in this case no
Content-Length is generated.
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/
Re: WebExternalResourceStream (Was: svn commit: r528885 - /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/WebExternalResourceStream.java)
Posted by Jean-Baptiste Quenot <jb...@apache.org>.
* Johan Compagner:
>
> Which one should be dropped? The ResourceStreaMRequestTarget?
> That will break all kinds of things. Then just adapt it the way you want.
Don't take "drop" literally, I mean make
WebExternalResourceRequestTarget reuse the
WebExternalResourceStream. I could change the implementation
indeed to implement buffering. But in the end, we'll end up with
many classes implementing buffering just for satisfying length().
So we could just allow to return -1, and the framework will take
care of the buffering. Actually, that's what is done in Cocoon,
when a resource stream does not provide the length, it overrides
shouldSetContentLength() returning true so that the underlying
pipeline buffers the output to compute the length.
I'm a bit reluctant to use ByteArrayOutputStream everywhere, you
see?
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/
Re: WebExternalResourceStream (Was: svn commit: r528885 - /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/WebExternalResourceStream.java)
Posted by Johan Compagner <jc...@gmail.com>.
On 4/15/07, Jean-Baptiste Quenot <jb...@apache.org> wrote:
>
> * Johan Compagner:
>
> > how is this class (WebExternalResourceStream.java) different to:
> > UrlResourceStream ??
>
> * UrlResourceStream implements IResource for URLs, uses URL.openConnection
> ()
> * WebExternalResourceStream implements IResource for a webapp URI,
> uses the servlet context
No if it is a file inside the web app. It will use it as a file.
If it isn't a file (inside the war or inside a jar or inside a war and a
jar) it will use the url.
And di remember that URS has special code so that we don't leak file
handles.
(work around a but in jre)
> and how is WebExternalResourceRequestTarget different to
> > ResourceStreamRequestTarget ?
>
> The former could be dropped, except that currently
> WebExternalResourceRequestTarget does not set Content-Length. If
> we use WebExternalResource + ResourceStreamRequestTarget it will
> throw an exception because length() is not implemented. I need to
> address that, but that means I need to buffer the resource in a
> ByteArrayOutputStream.
Which one should be dropped? The ResourceStreaMRequestTarget?
That will break all kinds of things. Then just adapt it the way you want.
johan
Re: WebExternalResourceStream (Was: svn commit: r528885 - /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/WebExternalResourceStream.java)
Posted by Johan Compagner <jc...@gmail.com>.
content lenght is used for all kind of things. For example caching.
So it is very recommended to set it.
johan
On 4/15/07, Jean-Baptiste Quenot <jb...@apache.org> wrote:
>
> The other possibility is to have a null value for
> IResourceStream.length(), like -1, to decide whether to set the
> header or not.
>
> The RFC says that this Content-Length SHOULD be sent
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
> That means it's recommended, but not mandatory.
> --
> Jean-Baptiste Quenot
> aka John Banana Qwerty
> http://caraldi.com/jbq/
>
Re: WebExternalResourceStream (Was: svn commit: r528885 - /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/WebExternalResourceStream.java)
Posted by Jean-Baptiste Quenot <jb...@apache.org>.
The other possibility is to have a null value for
IResourceStream.length(), like -1, to decide whether to set the
header or not.
The RFC says that this Content-Length SHOULD be sent
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
That means it's recommended, but not mandatory.
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/