Skip to content

Commit

Permalink
Issue #3916 - Fixing broken Content-Length evaluation
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Aug 8, 2020
1 parent 1f14dfa commit 2206b3e
Showing 1 changed file with 9 additions and 8 deletions.
Expand Up @@ -789,16 +789,17 @@ public String toString()
for (InclusiveByteRange ibr : ranges)
{
header[i] = ibr.toHeaderRangeString(content_length);
length +=
((i > 0) ? 2 : 0) +
2 + multi.getBoundary().length() + 2 +
(mimetype == null ? 0 : HttpHeader.CONTENT_TYPE.asString().length() + 2 + mimetype.length()) + 2 +
HttpHeader.CONTENT_RANGE.asString().length() + 2 + header[i].length() + 2 +
2 +
(ibr.getLast() - ibr.getFirst()) + 1;
if (i > 0) // in-part
length += 2;
length += 2 + multi.getBoundary().length() + 2; // "--" boundary CR LF
if (mimetype != null)
length += HttpHeader.CONTENT_TYPE.asString().length() + 2 + mimetype.length() + 2; // "Content-Type" ": " <len> CR LF
length += HttpHeader.CONTENT_RANGE.asString().length() + 2 + header[i].length() + 2; // "Content-Range" ": " <len> CR LF
length += 2; // CR LF
length += ((ibr.getLast() - ibr.getFirst()) + 1); // content size
i++;
}
length += 2 + 2 + multi.getBoundary().length() + 2 + 2;
length += 2 + 2 + multi.getBoundary().length() + 2 + 2; // CR LF "--" boundary "--" CR LF
response.setContentLength(length);

try (RangeWriter rangeWriter = HttpContentRangeWriter.newRangeWriter(content))
Expand Down

0 comments on commit 2206b3e

Please sign in to comment.