rejetto forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - hanshenrik

Pages: 1
1
HFS ~ HTTP File Server / how to inline images in folder view
« on: April 16, 2022, 07:34:01 AM »
i was initially going to ask the forum how to inline images, but i figured it out before completing my post :)
 
but because i didn't find a solution while searching the forum, here's how i did it:

go menu -> HTML Template -> Edit

then find
Code: [Select]
[box folder]
<fieldset id='folder'>

and replace it with
Code: [Select]
[box folder]
<fieldset id='folder'>
<script>
// the DOMContentLoaded is only needed because im too lazy to figure out how to add the script to the end of the pageload
document.addEventListener("DOMContentLoaded",function(){
//return;
                // ??? is it 42 or 43 or both?
$("#files img[src='/~img43'],#files img[src='/~img42']").parent().each(function(){
let preview_size = "250px";
let inline_image = document.createElement("img");
inline_image.name="inline_image";
inline_image.style = "max-width: "+preview_size+";"
inline_image.src = this.href;
inline_image.addEventListener("click",function(ev){
if(ev.target.style["max-width"]){
ev.target.style["max-width"]="";
} else{
ev.target.style["max-width"]=preview_size;
}
});
this.parentNode.appendChild(document.createElement("br"));
this.parentNode.appendChild(inline_image);
});
});
</script>
and all the images in folders will be inlined :)

before:

after:

2
on hfs 2.3m and "2.4.0 RC6" range requests are broken, if you request bytes out of range, the http request will just hang indefinitely!
this is mostly bad because it breaks wget's ` wget -r -c url` , but it could likely also likely be abused to implement a very efficient DoS attack,

if you have 123.txt containing the exact text "123" (and no newline), doing
> curl 'http://127.0.0.1/123.txt' -H "Range: bytes=3-"

the correct response would be "HTTP 416 Requested Range Not Satisfiable" (because only byte 0-2 inclusive exists),
 but that doesn't happen, instead the http connection will just hang indefinitely! hfs never responds, it just keeps the tcp connection alive indefinitely..!

3
Bug reports / file-extension-based-content-type ?
« on: June 24, 2021, 05:51:32 PM »
(didn't know where to post feature requests, if this is the wrong place, please let me know the correct place)

would be really nice if we could set content-type headers for file extensions somewhere,

very specifically, i want .mp4 files to be served with the header
Content-Type: video/mp4
not
Content-Type: application/octet-stream

this would allow me to stream mp4 files directly in my web browser, instead of having browsers download the video.

Pages: 1