https://bz.apache.org/bugzilla/show_bug.cgi?id=61524

--- Comment #3 from Boris Petrov <boris_pet...@live.com> ---
A little bit more info - I've updated Tomcat to 8.5.21 and Jersey to 2.26. The
exception happens again. The following occurs:

1) I hard-refresh the page where a tiff image is shown in an <img> tag. Nothing
happens.

2) I soft-refresh the page - the exception happens then. What is interesting is
the request that Chrome has made - it contains a "Range:bytes=519677-519677"
header. Our guess is that Chrome has cached the URL and "knows" this is an
image and needs more bytes or something. We respond with "content-length:1,
content-range:bytes 519677-519677/27672280" which causes the exception I guess.

This is the MessageBodyWriter we use:

@Override
public void writeTo(ContentRangeProxy t, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
                MultivaluedMap<String, Object> httpHeaders, OutputStream
entityStream) throws IOException {

        try (InputStream inputStream = t.content.getStream()) {
                if (t.rangeHeader != null) {
                        try (InputStream cutInputStream =
t.rangeHeader.cutStream(inputStream, t.content.getSize().getValue())) {
                                ByteStreams.copy(cutInputStream, entityStream);
                        }
                } else {
                        ByteStreams.copy(inputStream, entityStream);
                }
        } catch (ClientAbortException exception) {
                // this is to handle the case when the HTTP connection is
closed and the entityStream becomes unwritable
        }
}

And the cutStream method is implemented like so:

public InputStream cutStream(InputStream stream, Long contentLength) throws
IOException {
        if (from != -1) {
                ByteStreams.skipFully(stream, from);
        }
        return to == -1 ?
                stream :
                ByteStreams.limit(stream, contentLength == null ? ((to - from)
+ 1) : getContentLength(contentLength));
}

I hope this helps a bit more.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to