def test_multipleRangeRequestWithRangeOverlappingEnd(self):
    '\n        The response to a request for multiple bytes ranges is a MIME-ish\n        multipart response, even when one of the ranged falls off the end of\n        the resource.\n        '
    startEnds = [(0, 2), (40, (len(self.payload) + 10))]
    rangeHeaderValue = b','.join([networkString(('%s-%s' % (s, e))) for (s, e) in startEnds])
    self.request.requestHeaders.addRawHeader(b'range', (b'bytes=' + rangeHeaderValue))
    self.resource.render(self.request)
    self.assertEqual(self.request.responseCode, http.PARTIAL_CONTENT)
    boundary = re.match(b'^multipart/byteranges; boundary="(.*)"$', self.request.responseHeaders.getRawHeaders(b'content-type')[0]).group(1)
    parts = self.parseMultipartBody(b''.join(self.request.written), boundary)
    self.assertEqual(len(startEnds), len(parts))
    for (part, (s, e)) in zip(parts, startEnds):
        self.assertEqual(networkString(self.resource.type), part[b'contentType'])
        (start, end, size) = part[b'contentRange']
        self.assertEqual(int(start), s)
        self.assertEqual(int(end), min(e, (self.resource.getFileSize() - 1)))
        self.assertEqual(int(size), self.resource.getFileSize())
        self.assertEqual(self.payload[s:(e + 1)], part[b'body'])
The response to a request for multiple bytes ranges is a MIME-ish
multipart response, even when one of the ranged falls off the end of
the resource.
def test_multipleRangeRequestWithRangeOverlappingEnd(self):
    '\n        The response to a request for multiple bytes ranges is a MIME-ish\n        multipart response, even when one of the ranged falls off the end of\n        the resource.\n        '
    startEnds = [(0, 2), (40, (len(self.payload) + 10))]
    rangeHeaderValue = b','.join([networkString(('%s-%s' % (s, e))) for (s, e) in startEnds])
    self.request.requestHeaders.addRawHeader(b'range', (b'bytes=' + rangeHeaderValue))
    self.resource.render(self.request)
    self.assertEqual(self.request.responseCode, http.PARTIAL_CONTENT)
    boundary = re.match(b'^multipart/byteranges; boundary="(.*)"$', self.request.responseHeaders.getRawHeaders(b'content-type')[0]).group(1)
    parts = self.parseMultipartBody(b.join(self.request.written), boundary)
    self.assertEqual(len(startEnds), len(parts))
    for (part, (s, e)) in zip(parts, startEnds):
        self.assertEqual(networkString(self.resource.type), part[b'contentType'])
        (start, end, size) = part[b'contentRange']
        self.assertEqual(int(start), s)
        self.assertEqual(int(end), min(e, (self.resource.getFileSize() - 1)))
        self.assertEqual(int(size), self.resource.getFileSize())
        self.assertEqual(self.payload[s:(e + 1)], part[b'body'])