code: def header_expand(headers):
      
  
      collector = []
  
      if isinstance(headers, dict):
          headers = headers.items()
  
      elif isinstance(headers, basestring):
          return headers
  
      for i, (value, params) in enumerate(headers):
  
          _params = []
  
          for (p_k, p_v) in params.items():
  
              _params.append('%s=%s' % (p_k, p_v))
  
          collector.append(value)
          collector.append('; ')
  
          if len(params):
  
              collector.append('; '.join(_params))
  
              if not len(headers) == i+1:
                  collector.append(', ')
  
  
      # Remove trailing separators.
      if collector[-1] in (', ', '; '):
          del collector[-1]
  
      return ''.join(collector)
docs: Returns an HTTP Header value string from a dictionary.
  
      Example expansion::
  
          {'text/x-dvi': {'q': '.8', 'mxb': '100000', 'mxt': '5.0'}, 'text/x-c': {}}
          # Accept: text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c
  
          (('text/x-dvi', {'q': '.8', 'mxb': '100000', 'mxt': '5.0'}), ('text/x-c', {}))
          # Accept: text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c