seasocks icon indicating copy to clipboard operation
seasocks copied to clipboard

Support Filedata return from a PageHandler

Open scallopedllama opened this issue 6 years ago • 2 comments

Though you can set up static file hosting based on the incoming URI, there appears to be no way to use the sendStaticData function from a dynamic Response from a PageHandler.

I would like to set up my server so that a CrackedUriPageHandler figures out what file the user wants based off of something in the request (like the query params) and uses something like sendStaticData to send a static file from the filesystem back to the client.

I noticed a relevant TODO in that method:

// TODO: fold this into the handler way of doing things.

scallopedllama avatar Jul 11 '18 19:07 scallopedllama

Indeed! Seasocks started as a pure websockets-and-static-file system. But grew up...and ended up having much more sophisticated page handling. Eventually it would be nice to handle the file serving just like a normal page, but there's a lot of things that need to be handled, like range requests and so on.

mattgodbolt avatar Jul 11 '18 23:07 mattgodbolt

I wrote up a class implementing a Response that can handle the file response stuff supporting file resuming and on-the-fly compression (which disables file resuming).

The Pull Request does not touch the sendStaticData method in Connection though. That could probably be updated to use this but I didn't immediately understand how. Also, the range header handling stuff in there did not appear to be correct to me.

scallopedllama avatar Aug 08 '18 18:08 scallopedllama