parameters: (header)
docstring: Verifies that header value is a string which doesn't contain
  
      leading whitespace or return characters. This prevents unintended
  
      header injection.
  
  
  
      :param header: tuple, in the format (name, value).
docstring_summary: Verifies that header value is a string which doesn't contain
docstring_tokens: Verifies that header value is a string which doesn t contain
function: def check_header_validity(header):
  
      """Verifies that header value is a string which doesn't contain
  
      leading whitespace or return characters. This prevents unintended
  
      header injection.
  
  
  
      :param header: tuple, in the format (name, value).
  
      """
  
      name, value = header
  
  
  
      if isinstance(value, bytes):
  
          pat = _CLEAN_HEADER_REGEX_BYTE
  
      else:
  
          pat = _CLEAN_HEADER_REGEX_STR
  
      try:
  
          if not pat.match(value):
  
              raise InvalidHeader("Invalid return character or leading space in header: %s" % name)
  
      except TypeError:
  
          raise InvalidHeader("Value for header {%s: %s} must be of type str or "
  
                              "bytes, not %s" % (name, value, type(value)))
function_tokens: def check_header_validity ( header ) : name , value = header if isinstance ( value , bytes ) : pat = _CLEAN_HEADER_REGEX_BYTE else : pat = _CLEAN_HEADER_REGEX_STR try : if not pat . match ( value ) : raise InvalidHeader ( "Invalid return character or leading space in header: %s" % name ) except TypeError : raise InvalidHeader ( "Value for header {%s: %s} must be of type str or " "bytes, not %s" % ( name , value , type ( value ) ) )