MCPcopy Index your code
hub / github.com/RustPython/RustPython / _parse_chunked

Method _parse_chunked

Lib/test/test_httplib.py:513–537  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

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
540class BasicTest(TestCase):

Callers 3

test_explicit_headersMethod · 0.95
test_requestMethod · 0.95

Calls 5

lenFunction · 0.85
splitMethod · 0.45
assertEqualMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected