Repository: yt-dlp/yt-dlp
File: yt_dlp/downloader/http.py (Python)

Code before:
                            ctx.resume_len = 0
                            ctx.open_mode = 'wb'
                            return
                elif err.code < 500 or err.code >= 600:
                    # Unexpected HTTP error
                    raise
                raise RetryDownload(err)
            except urllib.error.URLError as err:
                if isinstance(err.reason, ssl.CertificateError):
                    raise
                raise RetryDownload(err)
            # In urllib.request.AbstractHTTPHandler, the response is partially read on request.
            # Any errors that occur during this will not be wrapped by URLError
            except RESPONSE_READ_EXCEPTIONS as err:
                raise RetryDownload(err)

        def close_stream():
            if ctx.stream is not None:
                if not ctx.tmpfilename == '-':
                    ctx.stream.close()
                ctx.stream = None

        def download():
            data_len = ctx.data.info().get('Content-length', None)

            if ctx.data.info().get('Content-encoding', None):
                # Content-encoding is present, Content-length is not reliable anymore as we are
                # doing auto decompression.
                data_len = None

            # Range HTTP header may be ignored/unsupported by a webserver
            # (e.g. extractor/scivee.py, extractor/bambuser.py).
            # However, for a test we still would like to download just a piece of a file.
            # To achieve this we limit data_len to _TEST_FILE_SIZE and manually control
            # block size when downloading a file.
            if is_test and (data_len is None or int(data_len) > self._TEST_FILE_SIZE):
                data_len = self._TEST_FILE_SIZE

            if data_len is not None:
                data_len = int(data_len) + ctx.resume_len
                min_data_len = self.params.get('min_filesize')
                max_data_len = self.params.get('max_filesize')
                if min_data_len is not None and data_len < min_data_len:
                    self.to_screen(
                        f'\r[download] File is smaller than min-filesize ({data_len} bytes < {min_data_len} bytes). Aborting.')
                    return False
                if max_data_len is not None and data_len > max_data_len:
                    self.to_screen(
                        f'\r[download] File is larger than max-filesize ({data_len} bytes > {max_data_len} bytes). Aborting.')
                    return False


Review comment (suggestion):
`None` is default?
```suggestion
            if ctx.data.info().get('Content-encoding'):
```
Or maybe 
```suggestion
            if ctx.data.info().get('Content-encoding') is not None:
```

Code after:
                            ctx.resume_len = 0
                            ctx.open_mode = 'wb'
                            return
                elif err.code < 500 or err.code >= 600:
                    # Unexpected HTTP error
                    raise
                raise RetryDownload(err)
            except urllib.error.URLError as err:
                if isinstance(err.reason, ssl.CertificateError):
                    raise
                raise RetryDownload(err)
            # In urllib.request.AbstractHTTPHandler, the response is partially read on request.
            # Any errors that occur during this will not be wrapped by URLError
            except RESPONSE_READ_EXCEPTIONS as err:
                raise RetryDownload(err)

        def close_stream():
            if ctx.stream is not None:
                if not ctx.tmpfilename == '-':
                    ctx.stream.close()
                ctx.stream = None

        def download():
            data_len = ctx.data.info().get('Content-length')

            if ctx.data.info().get('Content-encoding'):
                # Content-encoding is present, Content-length is not reliable anymore as we are
                # doing auto decompression. (See: https://github.com/yt-dlp/yt-dlp/pull/6176)
                data_len = None

            # Range HTTP header may be ignored/unsupported by a webserver
            # (e.g. extractor/scivee.py, extractor/bambuser.py).
            # However, for a test we still would like to download just a piece of a file.
            # To achieve this we limit data_len to _TEST_FILE_SIZE and manually control
            # block size when downloading a file.
            if is_test and (data_len is None or int(data_len) > self._TEST_FILE_SIZE):
                data_len = self._TEST_FILE_SIZE

            if data_len is not None:
                data_len = int(data_len) + ctx.resume_len
                min_data_len = self.params.get('min_filesize')
                max_data_len = self.params.get('max_filesize')
                if min_data_len is not None and data_len < min_data_len:
                    self.to_screen(
                        f'\r[download] File is smaller than min-filesize ({data_len} bytes < {min_data_len} bytes). Aborting.')
                    return False
                if max_data_len is not None and data_len > max_data_len:
                    self.to_screen(
                        f'\r[download] File is larger than max-filesize ({data_len} bytes > {max_data_len} bytes). Aborting.')
                    return False