Http module

file_response

procedure · 1 overloadsince 0.30.0Source

A response with the contents of the file at path, read in pieces as the client takes them (Content-Length is the file's size when the response is sent). An empty content_type is chosen from the file's extension (application/octet-stream when unknown). A file that cannot be opened is a 404, or a 500 for any other failure; a file that shrinks while it is sent cuts the connection.

file_response :: (path: string, content_type := "", status := 200) -> Response

A response with the contents of the file at path, read in pieces as the client takes them (Content-Length is the file's size when the response is sent). An empty content_type is chosen from the file's extension (application/octet-stream when unknown). A file that cannot be opened is a 404, or a 500 for any other failure; a file that shrinks while it is sent cuts the connection.

Parameters

path: string
the file to send.
content_type := ""
the Content-Type header value. Empty picks one from the extension.
status := 200
the HTTP status code.

Returns

See also