Skip to content

Content-Disposition headers #8950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Myestery
Copy link

@Myestery Myestery commented Jul 17, 2025

Update Content-Disposition header to include 'inline' for image responses.

meant to fix #8914

Old Behaviour

As seen in the linked issue, when Content Disposition is fetched for an image using the view_image function, it is erroneous to parse as it doesn't follow RFC standard

Screenshot 2025-07-18 at 00 41 46

New Behaviour

Standard RFC pattern for Content Disposition is used to render images inline in the browser ( 100% backwards compatible as this is the browser's default)
Screenshot 2025-07-18 at 00 43 37

@Myestery Myestery changed the title WIP Content-Disposition headers Content-Disposition headers Jul 17, 2025
@Myestery Myestery marked this pull request as ready for review July 17, 2025 23:47
@Myestery Myestery requested a review from comfyanonymous as a code owner July 17, 2025 23:47
Copy link

@OrangeDoro OrangeDoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I'm a grad student working on a research project about using large language models to automate code review. Based on your commit 3e53e19 and the changes in server.py, my tool generated this comment:

  1. Filename Handling: Sanitize the filename variable to ensure it does not contain malicious characters or patterns to prevent vulnerabilities such as directory traversal attacks or header injection.
  2. Error Handling: Implement proper error handling to manage cases where the image file cannot be processed or opened, ensuring that error messages do not leak sensitive information.
  3. Null Checks for filename: Add a check for filename to ensure it is a valid string before constructing the headers.
  4. Handling of request.rel_url.query: Ensure that request.rel_url.query is valid and handle cases where it might not be as expected.
  5. Content-Disposition Header Change: Ensure that the change from attachment to inline aligns with the intended behavior of the application. If users expect to download images, consider retaining the attachment disposition.
  6. Consistency Across Responses: Confirm that the change to inline is desired for all instances of the Content-Disposition header in the function.
  7. Buffer Management: Implement limits on the size of the images that can be processed and served. Consider using streaming responses for large files to avoid loading the entire file into memory at once.
  8. Common Logic: Create a helper function to handle the response creation to reduce code duplication and enhance readability.
  9. Response Type Tests: Add tests to validate the response type based on the image format and ensure that the correct content_type is returned for different image formats.
  10. Behavioral Tests for Different Channels: Add tests that cover different channel types (e.g., 'rgba', 'a') to ensure that the correct response is generated for each.
  11. Testing: Ensure that there are tests in place to verify that the images are being served correctly with the new Content-Disposition header, including checking that images display correctly in the browser.
  12. Logging: Add logging to capture the Content-Disposition header and the filename being returned, as well as any errors that occur during image processing.
  13. Separation of Concerns: Refactor to separate image processing and response generation into distinct functions for better maintainability.

As part of my research, I'm trying to understand how useful these comments are in real-world development. If you have a moment, I'd be super grateful if you could quickly reply to these two yes/no questions:

  1. Does this comment provide suggestions from a dimension you hadn’t considered?

  2. Do you find this comment helpful?

Thanks a lot for your time and feedback! And sorry again if this message is a bother.

@jtydhr88
Copy link
Contributor

jtydhr88 commented Jul 20, 2025

hi @OrangeDoro, same to #8716, I suggest do not use working/reviewing PR for your study, it may be confuse for later core team reviewer.
Other than these, I suggest you choose draft PRs which put on hold, for example, you could use #8265 and Comfy-Org/ComfyUI_frontend#3976 which contain BE and FE changes, I am the owner of these two PRs

@kevinpaik1
Copy link

PR Review Summary

Status: ✅ Approved for Core Team Review

For the Contributor

Thank you for this clean fix to the Content-Disposition headers! Your PR properly addresses issue #8914 by making the headers RFC 6266 compliant. The implementation is minimal and correct - exactly what we want to see.

Technical Summary

  • Scope: Updates Content-Disposition headers to include 'inline' directive
  • Files Changed: 1 file (+4/-4 lines)
  • Build Status: ✅ PASS
  • Test Status: ✅ PASS (manual verification)
  • Security: ✅ Clean
  • Architecture: ✅ Aligned

Review Highlights

Strengths:

  • Follows RFC 6266 standard correctly
  • Minimal change that solves the specific issue
  • Maintains full backward compatibility
  • Good documentation with before/after evidence

Key Findings:

  • The 'inline' directive is the browser default, so this change explicitly declares existing behavior
  • No security implications as filename parameter is already validated
  • Performance impact is negligible (7 bytes per response)

Remaining Items: None

Next Steps

This PR is ready for core team review. The core team will conduct their own evaluation and may request additional changes before merge.

For Core Team

Focus Areas: Standard review - RFC compliance verification
Review Complexity: Low - straightforward header format fix

Copy link
Collaborator

@guill guill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good and safe fix.

@guill
Copy link
Collaborator

guill commented Jul 23, 2025

It looks like you may need to merge back from main (or rebase) to get the updates that allow you to pass the new Windows Line Endings CI. Apologies for the inconvenience.

@Myestery
Copy link
Author

all done @guill

@guill guill added the Good PR This PR looks good to go, it needs comfy's final review. label Jul 23, 2025
@kevinpaik1
Copy link

Thank you for your contribution @Myestery!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good PR This PR looks good to go, it needs comfy's final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Content-Disposition" Header set in view_image function not matching RFC2183 rules
5 participants