From 0c2f90ee5c713fcb3aedb236fcebe7dd6d323ba3 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Wed, 2 Mar 2011 22:25:09 +0100 Subject: Add ability to serve parts of a file. --- http_static.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'http_static.cpp') diff --git a/http_static.cpp b/http_static.cpp index 7f56744..a0856f4 100644 --- a/http_static.cpp +++ b/http_static.cpp @@ -19,12 +19,8 @@ void HTTP::Static::operator()(Connection::p connection) { } if(fs::is_regular_file(path)) { - fs::ifstream is(path, std::ios::in | std::ios::binary); - is.seekg(0, std::ios::end); - connection->add_header("content-length", boost::str(boost::format("%d") % is.tellg())); - is.seekg(0, std::ios::beg); - - connection->send_data(is); + connection->send_file(path); + } else if(fs::exists(path)) { connection->send_error(403); } else { -- cgit v1.2.3