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

Function check_headers

Lib/wsgiref/validate.py:386–409  ·  view source on GitHub ↗
(headers)

Source from the content-addressed store, hash-verified

384 % status, WSGIWarning)
385
386def check_headers(headers):
387 assert_(type(headers) is list,
388 "Headers (%r) must be of type list: %r"
389 % (headers, type(headers)))
390 for item in headers:
391 assert_(type(item) is tuple,
392 "Individual headers (%r) must be of type tuple: %r"
393 % (item, type(item)))
394 assert_(len(item) == 2)
395 name, value = item
396 name = check_string_type(name, "Header name")
397 value = check_string_type(value, "Header value")
398 assert_(name.lower() != 'status',
399 "The Status header cannot be used; it conflicts with CGI "
400 "script, and HTTP status is not given through headers "
401 "(value: %r)." % value)
402 assert_('\n' not in name and ':' not in name,
403 "Header names may not contain ':' or '\\n': %r" % name)
404 assert_(header_re.search(name), "Bad header name: %r" % name)
405 assert_(not name.endswith('-') and not name.endswith('_'),
406 "Names may not end in '-' or '_': %r" % name)
407 if bad_header_value_re.search(value):
408 assert_(0, "Bad header value: %r (bad char: %r)"
409 % (value, bad_header_value_re.search(value).group(0)))
410
411def check_content_type(status, headers):
412 status = check_string_type(status, "Status")

Callers 1

start_response_wrapperFunction · 0.85

Calls 6

assert_Function · 0.85
check_string_typeFunction · 0.85
lowerMethod · 0.45
searchMethod · 0.45
endswithMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…