MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / check_headers

Function check_headers

tools/python-3.11.9-amd64/Lib/wsgiref/validate.py:389–412  ·  view source on GitHub ↗
(headers)

Source from the content-addressed store, hash-verified

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

Callers 1

start_response_wrapperFunction · 0.85

Calls 7

assert_Function · 0.85
check_string_typeFunction · 0.85
endswithMethod · 0.80
typeClass · 0.50
lowerMethod · 0.45
searchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected