You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: