Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router Additions #13

Merged
merged 8 commits into from
Nov 17, 2024
Merged

Router Additions #13

merged 8 commits into from
Nov 17, 2024

Conversation

mookums
Copy link
Owner

@mookums mookums commented Nov 16, 2024

This PR iterates on the current Router by bringing in both QOL features and necessary security hardening.

  • Router now provides a serve_not_found route where you can provide a handler for deciding what happens when a Not Found route is triggered. The basic example is updated to highlight use of it.
  • Router now ensures that any queries to the serve_fs_dir path rely within the path, preventing path traversal attacks that may have been possible before.
  • Router now will attach an ETag to any files served through serve_fs_dir, allowing for rudimentary caching using the size and last modified time. It will automatically return 304 if the browser/client requests a matching file.
  • Serving from the filesystem no longer requires the entire file to be copied into memory, reducing both the memory footprint of serve_fs_dir and also allowing for files that are larger than RAM to be served (eg. 100 GB file on 16 GB of RAM). This is thanks to Tardy.
  • Fixes a bug within the SSE implementation that may have led to connections entering a recv state if the data that was being sent to the client got fragmented by the kernel.

@mookums mookums merged commit 9d5a1d9 into main Nov 17, 2024
2 checks passed
@mookums mookums deleted the router-update branch November 17, 2024 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant