<commit_before>use std::io::{IoResult, File};
use std::io::util::copy;

//! An alias of the rust-http Response struct.

pub use Response = http::server::response::ResponseWriter;

pub trait ServeFile: Writer {
    fn serve_file(&mut self, &Path) -> IoResult<()>;
}

impl<'a> ServeFile for Response<'a> {
    fn serve_file(&mut self, path: &Path) -> IoResult<()> {
        let mut file = try!(File::open(path));
        copy(&mut file, self)
    }
}<commit_msg>(doc) Documented ServeFile trait.<commit_after>//! An augmentation of the rust-http Response struct.

use std::io::{IoResult, File};
use std::io::util::copy;

pub use Response = http::server::response::ResponseWriter;

/// Allow file-serving
pub trait ServeFile: Writer {
    /// Serve the file located at `path`.
    ///
    /// This is usually a terminal process, and `Middleware` may want to
    /// call `Unwind` after a file is served. If the status should be
    /// anything other than `200`, the `Middleware` must set it, including in
    /// the case of an `Err`.
    ///
    /// `serve_file` will err out if the file does not exist, the process
    /// does not have correct permissions, or it has other issues in reading
    /// from the file. Middleware should handle this gracefully.
    fn serve_file(&mut self, &Path) -> IoResult<()>;
}

impl<'a> ServeFile for Response<'a> {
    fn serve_file(&mut self, path: &Path) -> IoResult<()> {
        let mut file = try!(File::open(path));
        copy(&mut file, self)
    }
}
{'fraction_non_alphanumeric': 0.1491638795986622, 'fraction_numerical': 0.002006688963210702, 'mean_word_length': 3.225988700564972, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3691818', 'n_tokens_mistral': 458, 'n_tokens_neox': 452, 'n_words': 167}