def parse_headers(message):
 headers_out = []
 if six.PY3:
  for (header, value) in message.items():
   if (header.lower() not in filtered_headers):
    headers_out.append((header, value))
 else:
  for full_header in message.headers:
   if (not full_header):
    continue
   if full_header[0].isspace():
    if (not headers_out):
     raise ValueError(('First header starts with a space (%r)' % full_header))
    (last_header, last_value) = headers_out.pop()
    value = ((last_value + ' ') + full_header.strip())
    headers_out.append((last_header, value))
    continue
   try:
    (header, value) = full_header.split(':', 1)
   except:
    raise ValueError(('Invalid header: %r' % full_header))
   value = value.strip()
   if (header.lower() not in filtered_headers):
    headers_out.append((header, value))
 return headers_out

def parse_headers ( message ) : headers_out = [ ] if six . PY3 : for ( header , value ) in message . items ( ) : if ( header . lower ( ) not in filtered_headers ) : headers_out . append ( ( header , value ) ) else : for full_header in message . headers : if ( not full_header ) : continue if full_header [ 0 ] . isspace ( ) : if ( not headers_out ) : raise ValueError ( ( 'First header starts with a space (%r)' % full_header ) ) ( last_header , last_value ) = headers_out . pop ( ) value = ( ( last_value + ' ' ) + full_header . strip ( ) ) headers_out . append ( ( last_header , value ) ) continue try : ( header , value ) = full_header . split ( ':' , 1 ) except : raise ValueError ( ( 'Invalid header: %r' % full_header ) ) value = value . strip ( ) if ( header . lower ( ) not in filtered_headers ) : headers_out . append ( ( header , value ) ) return headers_out
build a _contentdisposition from header values .