MCPcopy Index your code
hub / github.com/python/cpython / _parse_chunked

Method _parse_chunked

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

Source from the content-addressed store, hash-verified

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

Callers 3

test_explicit_headersMethod · 0.95
test_requestMethod · 0.95

Calls 4

splitMethod · 0.45
assertEqualMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected