parameters: (self, v)
docstring: Return the given header name or value, encoded for HTTP output.
docstring_summary: Return the given header name or value, encoded for HTTP output.
docstring_tokens: Return the given header name or value encoded for HTTP output .
function: def encode(self, v):
          """Return the given header name or value, encoded for HTTP output."""
          for enc in self.encodings:
              try:
                  return v.encode(enc)
              except UnicodeEncodeError:
                  continue
          
          if self.protocol == (1, 1) and self.use_rfc_2047:
              # Encode RFC-2047 TEXT 
              # (e.g. u"\u8200" -> "=?utf-8?b?6IiA?="). 
              # We do our own here instead of using the email module
              # because we never want to fold lines--folding has
              # been deprecated by the HTTP working group.
              v = b2a_base64(v.encode('utf-8'))
              return (ntob('=?utf-8?b?') + v.strip(ntob('\n')) + ntob('?='))
          
          raise ValueError("Could not encode header part %r using "
                           "any of the encodings %r." %
                           (v, self.encodings))
function_tokens: def encode ( self , v ) : for enc in self . encodings : try : return v . encode ( enc ) except UnicodeEncodeError : continue if self . protocol == ( 1 , 1 ) and self . use_rfc_2047 : # Encode RFC-2047 TEXT  # (e.g. u"\u8200" -> "=?utf-8?b?6IiA?=").  # We do our own here instead of using the email module # because we never want to fold lines--folding has # been deprecated by the HTTP working group. v = b2a_base64 ( v . encode ( 'utf-8' ) ) return ( ntob ( '=?utf-8?b?' ) + v . strip ( ntob ( '\n' ) ) + ntob ( '?=' ) ) raise ValueError ( "Could not encode header part %r using " "any of the encodings %r." % ( v , self . encodings ) )