| 25 | self._path_whitelist = path_whitelist or [] |
| 26 | |
| 27 | def __call__(self, environ, start_response): |
| 28 | # Forces eventlet to respond immediately upon receiving a new chunk from endpoint rather |
| 29 | # than buffering it until the sufficient chunk size is reached. The order for this |
| 30 | # middleware is not important since it acts as pass-through. |
| 31 | |
| 32 | matches = False |
| 33 | req_path = environ.get("PATH_INFO", None) |
| 34 | |
| 35 | if not self._path_whitelist: |
| 36 | matches = True |
| 37 | else: |
| 38 | for path_whitelist in self._path_whitelist: |
| 39 | if fnmatch.fnmatch(req_path, path_whitelist): |
| 40 | matches = True |
| 41 | break |
| 42 | |
| 43 | if matches: |
| 44 | environ["eventlet.minimum_write_chunk_size"] = 0 |
| 45 | |
| 46 | return self.app(environ, start_response) |