Feature #778
closedcontent-disposition modification
Description
If a file is to be shown in a plugin, you can stress this by adding a Content-Disposition: inline header. If you also add a filename, many browsers show the filename in the title, which is nicer than a random URL.
WResource should get a new method that allows the content-disposition to be set to inline or attachment.
Current situation:
suggestFilename -> Content-Disposition: attachment; filename=..
no suggestFilename -> No Content-Disposition header.
Desired situation:
suggestFilename -> Content-Disposition: [attachment|inline]; filename=...
no suggestFilename -> No Content-Disposition header.
Note: According to rfc2183.txt, you can only suggest a filename when you also set inline or attachment as content-disposition. However, you can specify inline or attachment without a filename. It has not been tested how browsers react on this.
The patch below demonstrates the principle.
diff ---git a/src/Wt/WResource.C b/src/Wt/WResource.C
index ae58eb2..ef110ef 100644
---- a/src/Wt/WResource.C
- b/src/Wt/WResource.C
@@ --136,7 +136,7 @@ void WResource::handle(WebRequest webRequest, WebResponse
// one without specified encoding (Chrome9,
fileField+= Utils::EncodeHttpHeaderField("filename", suggestedFileName_);
response.addHeader("Content-Disposition", - "attachment;" + fileField);
- "inline;" + fileField);
}
handleRequest(request, response);
Updated by Wim Dumon over 13 years ago
- Status changed from New to Resolved
- Assignee changed from Koen Deforche to Wim Dumon
- % Done changed from 0 to 100
Done
Updated by Koen Deforche over 13 years ago
- Status changed from Resolved to Closed