1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-09 08:50:26 +00:00

Fix streaming of attachment tiddlers from recipe URIs

This commit is contained in:
Jeremy Ruston 2024-12-10 10:36:08 +00:00
parent e3ce053745
commit 239aacfa03

View File

@ -41,17 +41,24 @@ exports.handler = function(request,response,state) {
return;
} else {
// This is not a JSON API request, we should return the raw tiddler content
var type = tiddlerInfo.tiddler.type || "text/plain";
const result = $tw.mws.store.getBagTiddlerStream(title,tiddlerInfo.bag_name);
if(result) {
if(!response.headersSent){
response.writeHead(200, "OK",{
Etag: state.makeTiddlerEtag(tiddlerInfo),
"Content-Type": type
Etag: state.makeTiddlerEtag(result),
"Content-Type": result.type
});
response.write(tiddlerInfo.tiddler.text || "",($tw.config.contentTypeInfo[type] ||{encoding: "utf8"}).encoding);
}
result.stream.pipe(response);
return;
} else {
if(!response.headersSent){
response.writeHead(404);
response.end();
}
return;
}
}
} else {
if(!response.headersSent) {
// Redirect to fallback URL if tiddler not found