def http_headers(s):
 d = {}
 for line in s.split('\r\n'):
  try:
   (key, value) = [i.strip() for i in line.split(':', 1)]
   d[key] = value
  except ValueError:
   pass
 return d

def http_headers ( s ) : d = { } for line in s . split ( '\r\n' ) : try : ( key , value ) = [ i . strip ( ) for i in line . split ( ':' , 1 ) ] d [ key ] = value except ValueError : pass return d
create a dictionary of data from raw http headers .