'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):

    startEnds = [(0, 2), (40, (len(self.payload) + 10))]
    rangeHeaderValue = ','.join([networkString(('%s-%s' % (s, e))) for (s, e) in startEnds])
    self.request.requestHeaders.addRawHeader('range', ('bytes=' + rangeHeaderValue))
    self.resource.render(self.request)
    self.assertEqual(self.request.responseCode, http.PARTIAL_CONTENT)
    boundary = re.match('^multipart/byteranges;    boundary="(.*)"$', self.request.responseHeaders.getRawHeaders('content-type')[0]).group(1)
    parts = self.parseMultipartBody(''.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['contentType'])
        (start, end, size) = part['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['body'])
