parameters: (self, amt=None, decode_content=None)
docstring: Similar to :meth:`HTTPResponse.read`, but with an additional
          parameter: ``decode_content``.
  
          :param decode_content:
              If True, will attempt to decode the body based on the
              'content-encoding' header.
docstring_summary: Similar to :meth:`HTTPResponse.read`, but with an additional
          parameter: ``decode_content``.
docstring_tokens: Similar to : meth : HTTPResponse . read but with an additional parameter : decode_content .
function: def read_chunked(self, amt=None, decode_content=None):
          """
          Similar to :meth:`HTTPResponse.read`, but with an additional
          parameter: ``decode_content``.
  
          :param decode_content:
              If True, will attempt to decode the body based on the
              'content-encoding' header.
          """
          self._init_decoder()
          # FIXME: Rewrite this method and make it a class with a better structured logic.
          if not self.chunked:
              raise ResponseNotChunked(
                  "Response is not chunked. "
                  "Header 'transfer-encoding: chunked' is missing.")
          if not self.supports_chunked_reads():
              raise BodyNotHttplibCompatible(
                  "Body should be httplib.HTTPResponse like. "
                  "It should have have an fp attribute which returns raw chunks.")
  
          # Don't bother reading the body of a HEAD request.
          if self._original_response and is_response_to_head(self._original_response):
              self._original_response.close()
              return
  
          with self._error_catcher():
              while True:
                  self._update_chunk_length()
                  if self.chunk_left == 0:
                      break
                  chunk = self._handle_chunk(amt)
                  decoded = self._decode(chunk, decode_content=decode_content,
                                         flush_decoder=False)
                  if decoded:
                      yield decoded
  
              if decode_content:
                  # On CPython and PyPy, we should never need to flush the
                  # decoder. However, on Jython we *might* need to, so
                  # lets defensively do it anyway.
                  decoded = self._flush_decoder()
                  if decoded:  # Platform-specific: Jython.
                      yield decoded
  
              # Chunk content ends with \r\n: discard it.
              while True:
                  line = self._fp.fp.readline()
                  if not line:
                      # Some sites may not end with '\r\n'.
                      break
                  if line == b'\r\n':
                      break
  
              # We read everything; close the "file".
              if self._original_response:
                  self._original_response.close()
function_tokens: def read_chunked ( self , amt = None , decode_content = None ) : self . _init_decoder ( ) # FIXME: Rewrite this method and make it a class with a better structured logic. if not self . chunked : raise ResponseNotChunked ( "Response is not chunked. " "Header 'transfer-encoding: chunked' is missing." ) if not self . supports_chunked_reads ( ) : raise BodyNotHttplibCompatible ( "Body should be httplib.HTTPResponse like. " "It should have have an fp attribute which returns raw chunks." ) # Don't bother reading the body of a HEAD request. if self . _original_response and is_response_to_head ( self . _original_response ) : self . _original_response . close ( ) return with self . _error_catcher ( ) : while True : self . _update_chunk_length ( ) if self . chunk_left == 0 : break chunk = self . _handle_chunk ( amt ) decoded = self . _decode ( chunk , decode_content = decode_content , flush_decoder = False ) if decoded : yield decoded if decode_content : # On CPython and PyPy, we should never need to flush the # decoder. However, on Jython we *might* need to, so # lets defensively do it anyway. decoded = self . _flush_decoder ( ) if decoded : # Platform-specific: Jython. yield decoded # Chunk content ends with \r\n: discard it. while True : line = self . _fp . fp . readline ( ) if not line : # Some sites may not end with '\r\n'. break if line == b'\r\n' : break # We read everything; close the "file". if self . _original_response : self . _original_response . close ( )