class static_file#

class static_file#

Provides a wrapper for handling static file response.

Public Functions

inline auto etag() const noexcept -> const http::header::entity_tag&#

Get ETag that will be used when converting to response.

inline auto content_type() const noexcept -> const mime::mime_view&#

Get Content-Type that will be used when converting to response.

inline void set_content_type(mime::mime_view mime) noexcept#

Set the Content-Type header that will be used when converting to response.

inline auto content_disposition() const noexcept -> const std::string&#

Get Content-Disposition that will be used when converting to response.

inline auto file() const noexcept -> const stream_file&#

Get the reference to the underlying stream_file.

inline auto file() noexcept -> stream_file&#

Get the reference to the underlying stream_file.

inline auto release() -> stream_file#

Release the underlying stream_file object.

Public Static Functions

static inline auto open(const executor_type &ex, const std::string &path) -> expected<static_file, std::error_code>#

Open file with read-only permission.

DESCRIPTION

Open file with read-only permission. Content-Type / Content-Disposition headers for the response will be obtained from the provided file extension.

static inline auto open(const executor_type &ex, const std::string &path, const request &req) -> expected<static_file, std::error_code>#

Open file with read-only permission.

DESCRIPTION

Open file with read-only permission. Range / If-None-Match / If-Modified-Since headers from the request will be handled automatically, and Content-Type / Content-Disposition headers for the response will be obtained from the provided file extension.