Compare commits

...

2 Commits

Author SHA1 Message Date
Nicola Urs Bruce Spieser
1b4e5bb99c
Merge e273c0d73f into fce0398470 2026-04-29 18:57:34 +08:00
Ocean
e273c0d73f 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
2026-02-16 22:50:12 +01:00

View File

@ -559,7 +559,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'
@ -579,7 +579,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:
@ -596,7 +596,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:
# Use the content type from asset resolution if available,
# otherwise guess from the filename.
@ -613,7 +613,7 @@ class PromptServer():
return web.FileResponse(
file,
headers={
"Content-Disposition": f"filename=\"{filename}\"",
"Content-Disposition": f"inline; filename=\"{filename}\"",
"Content-Type": content_type
}
)