summaryrefslogtreecommitdiff
path: root/http_static.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-03-02 22:25:09 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-03-02 22:25:09 +0100
commit0c2f90ee5c713fcb3aedb236fcebe7dd6d323ba3 (patch)
tree5cd273e39a9679afd75a97bdb2bb6d1f839b0dc9 /http_static.cpp
parent0649a5c78eeef6eba731ee1c698e18554cad5670 (diff)
Add ability to serve parts of a file.
Diffstat (limited to 'http_static.cpp')
-rw-r--r--http_static.cpp8
1 files changed, 2 insertions, 6 deletions
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 {