1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-09 17:00:27 +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,16 +41,23 @@ exports.handler = function(request,response,state) {
return; return;
} else { } else {
// This is not a JSON API request, we should return the raw tiddler content // 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(!response.headersSent) { if(result) {
response.writeHead(200, "OK",{ if(!response.headersSent){
Etag: state.makeTiddlerEtag(tiddlerInfo), response.writeHead(200, "OK",{
"Content-Type": type Etag: state.makeTiddlerEtag(result),
}); "Content-Type": result.type
response.write(tiddlerInfo.tiddler.text || "",($tw.config.contentTypeInfo[type] ||{encoding: "utf8"}).encoding); });
response.end(); }
result.stream.pipe(response);
return;
} else {
if(!response.headersSent){
response.writeHead(404);
response.end();
}
return;
} }
return;
} }
} else { } else {
if(!response.headersSent) { if(!response.headersSent) {