From 47f60527e264c6842fb587eec51aeec3949a492c Mon Sep 17 00:00:00 2001 From: LincolnBurrows2017 Date: Fri, 13 Mar 2026 10:40:57 +0000 Subject: [PATCH 1/2] fix: Content-Disposition header to comply with RFC2183 Changed Content-Disposition header from 'filename=...' to 'attachment; filename=...' to comply with RFC 2183. This fixes issue #8914 where third-party downloading libraries fail to parse the filename correctly due to incorrect header format. Fixes: https://github.com/Comfy-Org/ComfyUI/issues/8914 --- server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 76904ebc9..8e738f0f5 100644 --- a/server.py +++ b/server.py @@ -523,7 +523,7 @@ class PromptServer(): buffer.seek(0) return web.Response(body=buffer.read(), content_type=f'image/{image_format}', - headers={"Content-Disposition": f"filename=\"{filename}\""}) + headers={"Content-Disposition": f"attachment; filename=\"{filename}\""}) if 'channel' not in request.rel_url.query: channel = 'rgba' @@ -543,7 +543,7 @@ class PromptServer(): buffer.seek(0) return web.Response(body=buffer.read(), content_type='image/png', - headers={"Content-Disposition": f"filename=\"{filename}\""}) + headers={"Content-Disposition": f"attachment; filename=\"{filename}\""}) elif channel == 'a': with Image.open(file) as img: @@ -560,7 +560,7 @@ class PromptServer(): alpha_buffer.seek(0) return web.Response(body=alpha_buffer.read(), content_type='image/png', - headers={"Content-Disposition": f"filename=\"{filename}\""}) + headers={"Content-Disposition": f"attachment; filename=\"{filename}\""}) else: # Get content type from mimetype, defaulting to 'application/octet-stream' content_type = mimetypes.guess_type(filename)[0] or 'application/octet-stream' @@ -572,7 +572,7 @@ class PromptServer(): return web.FileResponse( file, headers={ - "Content-Disposition": f"filename=\"{filename}\"", + "Content-Disposition": f"attachment; filename=\"{filename}\"", "Content-Type": content_type } ) From 7b8983bb3429d7c02d4a882b7648cccf4b33a4f3 Mon Sep 17 00:00:00 2001 From: Xiao Ji Ji Date: Mon, 16 Mar 2026 06:38:13 +0000 Subject: [PATCH 2/2] fix: replace bare except with json.JSONDecodeError in app_settings.py Changed bare except clause to catch json.JSONDecodeError specifically when loading user settings JSON file. This ensures that: - Only JSON parsing errors are caught (not SystemExit, KeyboardInterrupt) - Debugging is easier as unexpected errors will propagate - Follows Python best practices for exception handling --- app/app_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app_settings.py b/app/app_settings.py index c7ac73bf6..6fd2fbaff 100644 --- a/app/app_settings.py +++ b/app/app_settings.py @@ -21,7 +21,7 @@ class AppSettings(): try: with open(file) as f: return json.load(f) - except: + except json.JSONDecodeError: logging.error(f"The user settings file is corrupted: {file}") return {} else: