Skip to content

Commit

Permalink
Merged branch 'jetty-9.4.x' into 'jetty-9.4.x-5079-ipv6_brackets'.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbordet committed Aug 8, 2020
2 parents d53d9d8 + dcf867c commit dd4c1db
Showing 1 changed file with 13 additions and 8 deletions.
Expand Up @@ -786,19 +786,24 @@ public String toString()
int length = 0;
String[] header = new String[ranges.size()];
int i = 0;
final int CRLF = "\r\n".length();
final int DASHDASH = "--".length();
final int BOUNDARY = multi.getBoundary().length();
final int FIELD_SEP = ": ".length();
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 += CRLF;
length += DASHDASH + BOUNDARY + CRLF;
if (mimetype != null)
length += HttpHeader.CONTENT_TYPE.asString().length() + FIELD_SEP + mimetype.length() + CRLF;
length += HttpHeader.CONTENT_RANGE.asString().length() + FIELD_SEP + header[i].length() + CRLF;
length += CRLF;
length += ibr.getSize();
i++;
}
length += 2 + 2 + multi.getBoundary().length() + 2 + 2;
length += CRLF + DASHDASH + BOUNDARY + DASHDASH + CRLF;
response.setContentLength(length);

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

0 comments on commit dd4c1db

Please sign in to comment.