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

Method read_headers

module/lib/wsgiserver/__init__.py:465–498  ·  view source on GitHub ↗

Read header lines from the incoming stream.

(self)

Source from the content-addressed store, hash-verified

463 self.ready = True
464
465 def read_headers(self):
466 """Read header lines from the incoming stream."""
467 environ = self.environ
468
469 while True:
470 line = self.rfile.readline()
471 if not line:
472 # No more data--illegal end of headers
473 raise ValueError("Illegal end of headers.")
474
475 if line == '\r\n':
476 # Normal end of headers
477 break
478
479 if line[0] in ' \t':
480 # It's a continuation line.
481 v = line.strip()
482 else:
483 k, v = line.split(":", 1)
484 k, v = k.strip().upper(), v.strip()
485 envname = "HTTP_" + k.replace("-", "_")
486
487 if k in comma_separated_headers:
488 existing = environ.get(envname)
489 if existing:
490 v = ", ".join((existing, v))
491 environ[envname] = v
492
493 ct = environ.pop("HTTP_CONTENT_TYPE", None)
494 if ct is not None:
495 environ["CONTENT_TYPE"] = ct
496 cl = environ.pop("HTTP_CONTENT_LENGTH", None)
497 if cl is not None:
498 environ["CONTENT_LENGTH"] = cl
499
500 def decode_chunked(self):
501 """Decode the 'chunked' transfer coding."""

Callers 2

_parse_requestMethod · 0.95
decode_chunkedMethod · 0.95

Calls 6

splitMethod · 0.80
joinMethod · 0.80
popMethod · 0.80
readlineMethod · 0.45
replaceMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected