def h2_safe_headers(headers):
 stripped = {i.lower().strip() for (k, v) in headers if (k == 'connection') for i in v.split(',')}
 stripped.add('connection')
 return [header for header in headers if (header[0] not in stripped)]

def h2_safe_headers ( headers ) : stripped = { i . lower ( ) . strip ( ) for ( k , v ) in headers if ( k == 'connection' ) for i in v . split ( ',' ) } stripped . add ( 'connection' ) return [ header for header in headers if ( header [ 0 ] not in stripped ) ]
this method takes a set of headers that are provided by the user and transforms them into a form that is safe for emitting over http/2 .