Skip to content

Reading files #36

@kappsegla

Description

@kappsegla

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions