def _parse_message(chunks):
 f = BytesIO(''.join(chunks))
 k = None
 v = ''
 eof = False
 for l in f:
  if l.startswith(' '):
   v += l[1:]
  else:
   if (k is not None):
    (yield (k, v.rstrip('\n')))
   if (l == '\n'):
    break
   (k, v) = l.split(' ', 1)
 else:
  eof = True
  if (k is not None):
   (yield (k, v.rstrip('\n')))
  (yield (None, None))
 if (not eof):
  (yield (None, f.read()))
 f.close()

def _parse_message ( chunks ) : f = BytesIO ( '' . join ( chunks ) ) k = None v = '' eof = False for l in f : if l . startswith ( ' ' ) : v += l [ 1 : ] else : if ( k is not None ) : ( yield ( k , v . rstrip ( '\n' ) ) ) if ( l == '\n' ) : break ( k , v ) = l . split ( ' ' , 1 ) else : eof = True if ( k is not None ) : ( yield ( k , v . rstrip ( '\n' ) ) ) ( yield ( None , None ) ) if ( not eof ) : ( yield ( None , f . read ( ) ) ) f . close ( )
parse a message with a list of fields and a body .