You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kalle Korhonen <ka...@gmail.com> on 2013/10/30 19:32:20 UTC

FF re-requests an image for content-disposition inline

Perhaps OT but likely useful for others. I had noticed long ago that
onActivate() for our generated images was often invoked twice for the same
generated image returned via StreamResponse. I didn't think much of it
since the images were small and efficiently cached. Now that I was
refactoring some code I decided to take a deeper look at the problem and to
my surprise, it seems that Firefox (at least recent versions) seems to
re-request an image with content-disposition "inline" or if not specified.
It's not our code path and it's not a visible thing when debugging client
network but I can see another thread starting to handle a new request right
after Jetty has committed the first response (and still hasn't finished
handling it). If I use content-disposition "attachment", the image is only
requested once. Chrome is all ok regardless of content-disposition. It's
still possible some other underlying factor is causing this in our
configuration but it seems outside of our application code.  Can anybody
explain why? This could explain some of the "onActivate called twice on
StreamREsponse" posts on this list. Sample code below, verify yourself.

Kalle

        return new StreamResponse() {
            @Override
            public void prepareResponse(Response response) {
                response.setHeader("Content-Disposition", "inline;
test-image.png");
            }

            @Override
            public InputStream getStream() throws IOException {
                return getClass().getResourceAsStream("/test-image.png");
            }

            @Override
            public String getContentType() {
                return "image/png";
            }
        };