fix: add disposition type to Content-Disposition header (RFC 2183)

The Content-Disposition header was set to 'filename="name.ext"' without
a disposition type, violating RFC 2183. This caused third-party HTTP
clients (e.g. Go's mime.ParseMediaType) to fail parsing the filename.

Added 'inline;' disposition type prefix to all Content-Disposition headers
in the /view endpoint.

Fixes #8914
This commit is contained in:
Ocean 2026-02-16 22:50:12 +01:00
parent 88e6370527
commit e273c0d73f

View File

@ -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"inline; 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"inline; 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"inline; 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"inline; filename=\"{filename}\"",
"Content-Type": content_type
}
)