(self, data)
| 511 | return request, headers, b'\r\n'.join(lines[n + 1:]) |
| 512 | |
| 513 | def _parse_chunked(self, data): |
| 514 | body = [] |
| 515 | trailers = {} |
| 516 | n = 0 |
| 517 | lines = data.split(b'\r\n') |
| 518 | # parse body |
| 519 | while True: |
| 520 | size, chunk = lines[n:n+2] |
| 521 | size = int(size, 16) |
| 522 | |
| 523 | if size == 0: |
| 524 | n += 1 |
| 525 | break |
| 526 | |
| 527 | self.assertEqual(size, len(chunk)) |
| 528 | body.append(chunk) |
| 529 | |
| 530 | n += 2 |
| 531 | # we /should/ hit the end chunk, but check against the size of |
| 532 | # lines so we're not stuck in an infinite loop should we get |
| 533 | # malformed data |
| 534 | if n > len(lines): |
| 535 | break |
| 536 | |
| 537 | return b''.join(body) |
| 538 | |
| 539 | |
| 540 | class BasicTest(TestCase): |
no test coverage detected