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(('Header value %s must be of type str or bytes, not %s' % (value, type(value))))

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 ( ( 'Header value %s must be of type str or bytes, not %s' % ( value , type ( value ) ) ) )
verifies that header value is a string which doesnt contain leading whitespace or return characters .