(self, data)
| 557 | return request, headers, b'\r\n'.join(lines[n + 1:]) |
| 558 | |
| 559 | def _parse_chunked(self, data): |
| 560 | body = [] |
| 561 | trailers = {} |
| 562 | n = 0 |
| 563 | lines = data.split(b'\r\n') |
| 564 | # parse body |
| 565 | while True: |
| 566 | size, chunk = lines[n:n+2] |
| 567 | size = int(size, 16) |
| 568 | |
| 569 | if size == 0: |
| 570 | n += 1 |
| 571 | break |
| 572 | |
| 573 | self.assertEqual(size, len(chunk)) |
| 574 | body.append(chunk) |
| 575 | |
| 576 | n += 2 |
| 577 | # we /should/ hit the end chunk, but check against the size of |
| 578 | # lines so we're not stuck in an infinite loop should we get |
| 579 | # malformed data |
| 580 | if n > len(lines): |
| 581 | break |
| 582 | |
| 583 | return b''.join(body) |
| 584 | |
| 585 | |
| 586 | class BasicTest(TestCase): |
no test coverage detected