(body)
| 104 | |
| 105 | |
| 106 | def _gzip_compress_fileobj(body): |
| 107 | compressed_obj = io.BytesIO() |
| 108 | with GzipFile(fileobj=compressed_obj, mode='wb') as gz: |
| 109 | while True: |
| 110 | chunk = body.read(8192) |
| 111 | if not chunk: |
| 112 | break |
| 113 | if isinstance(chunk, str): |
| 114 | chunk = chunk.encode('utf-8') |
| 115 | gz.write(chunk) |
| 116 | compressed_obj.seek(0) |
| 117 | return compressed_obj |
| 118 | |
| 119 | |
| 120 | def _set_compression_header(headers, encoding): |
no test coverage detected