# Buggy code
def iter_content(self, chunk_size=1, decode_unicode=False):
    """Iterates over the response data.  When stream=True is set on the
    request, this avoids reading the content at once into memory for
    large responses.  The chunk size is the number of bytes it should
    read into memory.  This is not necessarily the length of each item
    returned as decoding can take place.

    chunk_size must be of type int or None. A value of None will
    function differently depending on the value of `stream`.
    stream=True will read data as it arrives in whatever size the
    chunks are received. If stream=False, data is returned as
    a single chunk.

    If decode_unicode is True, content will be decoded using the best
    available encoding based on the response.
    """

    def generate():
        # Special case for urllib3.
        if hasattr(self.raw, "stream"):
            try:
                for chunk in self.raw.stream(chunk_size, decode_content=True):
                    yield chunk
            except ProtocolError as e:
                raise ChunkedEncodingError(e)
            except DecodeError as e:
                raise ContentDecodingError(e)
            except ReadTimeoutError as e:
                raise ConnectionError(e)
        else:
            # Standard file-like object.
            while True:
                chunk = self.raw.read(chunk_size)
                if not chunk:
                    break
                yield chunk

        self._content_consumed = True

    if self._content_consumed and isinstance(self._content, bool):
        raise StreamConsumedError()
    elif chunk_size is not None and not isinstance(chunk_size, int):
        raise TypeError(
            "chunk_size must be an int, it is instead a %s." % type(chunk_size)
        )
    # simulate reading small chunks of the content
    reused_chunks = iter_slices(self._content, chunk_size)

    stream_chunks = generate()

    chunks = reused_chunks if self._content_consumed else stream_chunks

    if decode_unicode:
        chunks = stream_decode_response_unicode(chunks, self)

    return chunks


# Traceback (thirdparty.requests.packages.urllib3.exceptions.DecodeError)
Traceback (most recent call last):
File "/root/RECON/dirsearch-master/thirdparty/requests/packages/urllib3/response.py", line 192, in _decode
data = self._decoder.decompress(data)
File "/root/RECON/dirsearch-master/thirdparty/requests/packages/urllib3/response.py", line 58, in decompress
return self._obj.decompress(data)
zlib.error: Error -3 while decompressing data: incorrect header check

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/RECON/dirsearch-master/thirdparty/requests/models.py", line 657, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/root/RECON/dirsearch-master/thirdparty/requests/packages/urllib3/response.py", line 303, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "/root/RECON/dirsearch-master/thirdparty/requests/packages/urllib3/response.py", line 452, in read_chunked
flush_decoder=True)
File "/root/RECON/dirsearch-master/thirdparty/requests/packages/urllib3/response.py", line 197, in _decode
"failed to decode it." % content_encoding, e)
thirdparty.requests.packages.urllib3.exceptions.DecodeError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/RECON/dirsearch-master/dirsearch.py", line 40, in <module>
main = Program()
File "/root/RECON/dirsearch-master/dirsearch.py", line 36, in __init__
self.controller = Controller(self.script_path, self.arguments, self.output)
File "/root/RECON/dirsearch-master/lib/controller/Controller.py", line 162, in __init__
self.wait()
File "/root/RECON/dirsearch-master/lib/controller/Controller.py", line 400, in wait
self.fuzzer.start()
File "/root/RECON/dirsearch-master/lib/core/Fuzzer.py", line 86, in start
self.setupScanners()
File "/root/RECON/dirsearch-master/lib/core/Fuzzer.py", line 62, in setupScanners
self.scanners[extension] = Scanner(self.requester, self.testFailPath, "." + extension)
File "/root/RECON/dirsearch-master/lib/core/Scanner.py", line 45, in __init__
self.setup()
File "/root/RECON/dirsearch-master/lib/core/Scanner.py", line 49, in setup
firstResponse = self.requester.request(firstPath)
File "/root/RECON/dirsearch-master/lib/connection/Requester.py", line 156, in request
timeout=self.timeout
File "/root/RECON/dirsearch-master/thirdparty/requests/sessions.py", line 482, in get
return self.request('GET', url, **kwargs)
File "/root/RECON/dirsearch-master/thirdparty/requests/sessions.py", line 470, in request
resp = self.send(prep, **send_kwargs)
File "/root/RECON/dirsearch-master/thirdparty/requests/sessions.py", line 610, in send
r.content
File "/root/RECON/dirsearch-master/thirdparty/requests/models.py", line 734, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/root/RECON/dirsearch-master/thirdparty/requests/models.py", line 662, in generate
raise ContentDecodingError(e)
thirdparty.requests.exceptions.ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check',))

# Fixed code
def iter_content(self, chunk_size=1, decode_unicode=False):
    """Iterates over the response data.  When stream=True is set on the
    request, this avoids reading the content at once into memory for
    large responses.  The chunk size is the number of bytes it should
    read into memory.  This is not necessarily the length of each item
    returned as decoding can take place.

    chunk_size must be of type int or None. A value of None will
    function differently depending on the value of `stream`.
    stream=True will read data as it arrives in whatever size the
    chunks are received. If stream=False, data is returned as
    a single chunk.

    If decode_unicode is True, content will be decoded using the best
    available encoding based on the response.
    """

    def generate():
        # Special case for urllib3.
        if hasattr(self.raw, "stream"):
            try:
                for chunk in self.raw.stream(chunk_size, decode_content=True):
                    yield chunk
            except ProtocolError as e:
                raise ChunkedEncodingError(e)
            except DecodeError as e:
                # Dirsearch only
                while True:
                    chunk = self.raw.read(chunk_size)
                    if not chunk:
                        break
                    yield chunk
            except ReadTimeoutError as e:
                raise ConnectionError(e)
        else:
            # Standard file-like object.
            while True:
                chunk = self.raw.read(chunk_size)
                if not chunk:
                    break
                yield chunk

        self._content_consumed = True

    if self._content_consumed and isinstance(self._content, bool):
        raise StreamConsumedError()
    elif chunk_size is not None and not isinstance(chunk_size, int):
        raise TypeError(
            "chunk_size must be an int, it is instead a %s." % type(chunk_size)
        )
    # simulate reading small chunks of the content
    reused_chunks = iter_slices(self._content, chunk_size)

    stream_chunks = generate()

    chunks = reused_chunks if self._content_consumed else stream_chunks

    if decode_unicode:
        chunks = stream_decode_response_unicode(chunks, self)

    return chunks