Skip to content

Commit

Permalink
Don't compress http response by default.
Browse files Browse the repository at this point in the history
Remove argument to disable it.

Add new --enable-compress-response-body argument to enable it.
  • Loading branch information
comfyanonymous committed Feb 7, 2025
1 parent b695176 commit 079eccc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion comfy/cli_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def is_valid_directory(path: Optional[str]) -> Optional[str]:

parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")

parser.add_argument("--disable-compres-response-body", action="store_true", help="Disable compressing response body.")
parser.add_argument("--enable-compress-response-body", action="store_true", help="Enable compressing response body.")

if comfy.options.args_parsing:
args = parser.parse_args()
Expand Down
7 changes: 4 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ async def cache_control(request: web.Request, handler):
async def compress_body(request: web.Request, handler):
accept_encoding = request.headers.get("Accept-Encoding", "")
response: web.Response = await handler(request)
if args.disable_compres_response_body:
return response
if not isinstance(response, web.Response):
return response
if response.content_type not in ["application/json", "text/plain"]:
Expand Down Expand Up @@ -165,7 +163,10 @@ def __init__(self, loop):
self.client_session:Optional[aiohttp.ClientSession] = None
self.number = 0

middlewares = [cache_control, compress_body]
middlewares = [cache_control]
if args.enable_compress_response_body:
middlewares.append(compress_body)

if args.enable_cors_header:
middlewares.append(create_cors_middleware(args.enable_cors_header))
else:
Expand Down

0 comments on commit 079eccc

Please sign in to comment.