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

Reading files #36

Open
kappsegla opened this issue Feb 1, 2022 · 0 comments
Open

Reading files #36

kappsegla opened this issue Feb 1, 2022 · 0 comments

Comments

@kappsegla
Copy link
Contributor

When answering a request from a client if the requested url is a file at some point we need to try to open that file, read it and send it to the outputstream of the socket. After creating a response header with the right Content-type and Content-length and sending that on the outputstream of the client socket we can read the file and send that also.

Can we create a method that can take parameters like a Path and an OutputStream and handle the actual copying of the file.
An alternative implementation for smaller files would be to load the complete file into an byte array and return that from a method. But shouln't be used on large files.

There are also more effective ways of copying files without having to load it into a byte array first and instead going from file to socket using channels and avoiding allocating objects on the heap. But that is something we can update to later when we get this to work.

@BorvD BorvD self-assigned this Feb 3, 2022
@kappsegla kappsegla reopened this Feb 4, 2022
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

No branches or pull requests

2 participants