MCPcopy
hub / github.com/django/django / read

Method read

django/http/multipartparser.py:449–473  ·  view source on GitHub ↗
(self, size=None)

Source from the content-addressed store, hash-verified

447 return self.position
448
449 def read(self, size=None):
450 def parts():
451 remaining = self._remaining if size is None else size
452 # do the whole thing in one shot if no limit was provided.
453 if remaining is None:
454 yield b"".join(self)
455 return
456
457 # otherwise do some bookkeeping to return exactly enough
458 # of the stream and stashing any extra content we get from
459 # the producer
460 while remaining != 0:
461 assert remaining > 0, "remaining bytes to read should never go negative"
462
463 try:
464 chunk = next(self)
465 except StopIteration:
466 return
467 else:
468 emitting = chunk[:remaining]
469 self.unget(chunk[remaining:])
470 remaining -= len(emitting)
471 yield emitting
472
473 return b"".join(parts())
474
475 def __next__(self):
476 """

Callers 4

_parseMethod · 0.45
__next__Method · 0.45
__init__Method · 0.45
parse_boundary_streamFunction · 0.45

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected