7 Jun 2012 17:04
IResourceStreamWriter#write
Hi Wicket Devs, (wicket 6.0.0-beta2 btw). Why does IResourceStreamWriter#write() take a Response and not an OutputStream? As I see it, ResourceStreamResource (which is called from ResourceStreamRequestHandler) is responsible for setting the headers for the response, and does. What more could the IResourceStreamWriter want to do with the response? AbstractResource#respond() calls ResourceStreamResource#newResourceResponse(), which returns all the headers in the ResourceReponse (using normal IResourceStream calls), and passes back a wrapped call to IResourceStreamWriter#write() as the writer callback. AbstractResource#respond() then sets the headers on the Response, then only calls IResourceStreamWriter#write() via the write callback only if AbstractResource thinks data needs to be written based on the values returned from the normal IResourceStream calls. So, if the IResourceStreamWriter sets different headers in its write() method to the values produced by calling lastModifiedTime() etc (I would consider this a bad idea, and probably wrong), there is a danger that unexpected behaviour may occur if AbstractResource#respond() decides NOT to call the writer callback (which will call IResourceStreamWriter#write()). The IResourceStreamWriter implementer may wonder why his headers are not being set. If the IResourceStreamWriter does not set any headers apart from the(Continue reading)
RSS Feed