"Content-Disposition" Header set in view_image function not matching RFC2183 rules
Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see how to disable custom nodes if you need help)
Expected Behavior
When a file is fetched from ComfyUI via the view_image function, the "Content-Disposition" response header will be set to something like filename=name.ext, which doesn't match with the definition of this specific header in RFC 2183.
This will cause certain common functions (e.g. mime.ParseMediaType in Golang) to produce an error instead of parsing out the filename successfully, thus preventing various third party downloading libraries from extracting the correct filename, leading to unexpected behavior in certain post-Comfy processing procedures.
Expected Behavior should be setting the "Content-Disposition" response header as specified in RFC 2183, which should be something like attachment; filename=name.ext.
Actual Behavior
"Content-Disposition" response header set to something like filename=name.ext.
Steps to Reproduce
Attempt downloading a file from "/view" URL route via various third party downloading libraries (e.g. grab in Golang), resulting in saving a file named "view" locally, which normally should be correctly named like "name.ext".
Debug Logs
HTTP/1.1 200 OK
Content-Disposition: filename="vace14b_00003.mp4"
Content-Type: video/mp4
Etag: "18521d76691232cf-3102a6e"
Last-Modified: Mon, 14 Jul 2025 12:20:00 GMT
Content-Length: 51391086
Accept-Ranges: bytes
Date: Tue, 15 Jul 2025 03:51:51 GMT
connection: keep-alive
Other
No response
what's the pay?
Hello, I'll take this on. It seems to be a straightforward formatting issue in . I'll submit a PR with the fix shortly.
Thanks for the review. The concern about transcoded responses (e.g., preview returning WEBP/JPEG when the backing file is PNG) is valid but out of scope for this PR, which specifically addresses the initial download case from issue #8914 where the file exists and the Content-Disposition header was being set to attachment; filename="" with no actual filename value.
For the transcoded preview case, a separate fix would be needed that dynamically determines the appropriate extension based on the actual content type being served. That is a different issue from what this PR resolves.
Hi! I can help fix the Content-Disposition header to match RFC2183 rules. I understand the HTTP specifications and can implement the correct formatting. Please assign this to me!
Proposal
Understanding the Issue
The view_image function in server.py sets the Content-Disposition header as filename=name.ext — missing the required attachment; disposition type prefix per RFC 2183. This breaks third-party HTTP clients that rely on strict RFC parsing (e.g. Go's mime.ParseMediaType, various download managers).
Fix Approach
In server.py, update the Content-Disposition header in view_image from:
'Content-Disposition': f'filename={filename}'
to:
'Content-Disposition': f'attachment; filename="{filename}"'
Additional hardening:
- Wrap the filename in double quotes as required by RFC 2183 for filenames with special characters
- URL-encode the filename for the
filename*extended parameter (RFC 5987) to properly handle non-ASCII characters:from urllib.parse import quote 'Content-Disposition': f"attachment; filename=\"{filename}\"; filename*=UTF-8''{quote(filename)}" - Verify
previewmode (inline viewing) should useinline;instead ofattachment;where appropriate
Timeline
- Implementation: a few hours (2-3 line change + edge case handling)
- Testing with Go
mime.ParseMediaTypeand browser download behavior: same day - PR ready: within 24 hours
Ready to start immediately.
Hi! I'd like to work on this bounty.
My Plan:
- Analyze the requirements
- Implement the solution
- Submit PR within 24-48 hours
Payment Address:
- Platform: OKX
- Token: USDT (TRC20)
- Address:
YOUR_USDT_ADDRESS_HERE
Let's get this done! 🚀
Hi! I'd like to work on this bounty.
My Plan:
- Analyze the requirements
- Implement the solution
- Submit PR within 24-48 hours
Payment Address:
- Platform: OKX
- Token: USDT (TRC20)
- Address:
YOUR_USDT_ADDRESS_HERE
Let's get this done! 🚀
/attempt
I am looking into this and will submit a PR shortly.