def parse_http_dict(header_val):
 if (not header_val):
  return {}
 ans = {}
 (sep, dquote) = ('="' if isinstance(header_val, bytes) else u'="')
 for item in parse_http_list(header_val):
  (k, v) = item.partition(sep)[::2]
  if k:
   if (v.startswith(dquote) and v.endswith(dquote)):
    v = v[1:(-1)]
   ans[k] = v
 return ans

def parse_http_dict ( header_val ) : if ( not header_val ) : return { } ans = { } ( sep , dquote ) = ( '="' if isinstance ( header_val , bytes ) else u'="' ) for item in parse_http_list ( header_val ) : ( k , v ) = item . partition ( sep ) [ : : 2 ] if k : if ( v . startswith ( dquote ) and v . endswith ( dquote ) ) : v = v [ 1 : ( - 1 ) ] ans [ k ] = v return ans
parse an http comma separated header with items of the form a=1 .