MCPcopy Create free account
hub / github.com/pyload/pyload / decode_chunked

Method decode_chunked

module/lib/wsgiserver/__init__.py:500–525  ·  view source on GitHub ↗

Decode the 'chunked' transfer coding.

(self)

Source from the content-addressed store, hash-verified

498 environ["CONTENT_LENGTH"] = cl
499
500 def decode_chunked(self):
501 """Decode the 'chunked' transfer coding."""
502 cl = 0
503 data = StringIO.StringIO()
504 while True:
505 line = self.rfile.readline().strip().split(";", 1)
506 chunk_size = int(line.pop(0), 16)
507 if chunk_size <= 0:
508 break
509## if line: chunk_extension = line[0]
510 cl += chunk_size
511 data.write(self.rfile.read(chunk_size))
512 crlf = self.rfile.read(2)
513 if crlf != "\r\n":
514 self.simple_response("400 Bad Request",
515 "Bad chunked transfer coding "
516 "(expected '\\r\\n', got %r)" % crlf)
517 return
518
519 # Grab any trailer headers
520 self.read_headers()
521
522 data.seek(0)
523 self.environ["wsgi.input"] = data
524 self.environ["CONTENT_LENGTH"] = str(cl) or ""
525 return True
526
527 def respond(self):
528 """Call the appropriate WSGI app and write its iterable output."""

Callers 1

_respondMethod · 0.95

Calls 7

simple_responseMethod · 0.95
read_headersMethod · 0.95
splitMethod · 0.80
popMethod · 0.80
readlineMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected