From 3568ebefab593ba03f3d874d5b2e130aec4f1a89 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Thu, 3 Mar 2011 12:33:05 +0100 Subject: Fixed content-type and range handling. --- http_connection.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'http_connection.cpp') diff --git a/http_connection.cpp b/http_connection.cpp index daba10b..61928d3 100644 --- a/http_connection.cpp +++ b/http_connection.cpp @@ -82,7 +82,10 @@ void HTTP::Connection::send_file(const fs::path& filename) { std::string::iterator it = std::find(range_str.begin(), range_str.end(), '-'); std::size_t begin = boost::lexical_cast(std::string(range_str.begin(), it)); - std::size_t end = boost::lexical_cast(std::string(it + 1, range_str.end())) + 1; + std::size_t end = length; + if(++it != range_str.end()) { + end = boost::lexical_cast(std::string(it, range_str.end())); + } // Is the range past the end of the file? if(end > length) { @@ -90,7 +93,7 @@ void HTTP::Connection::send_file(const fs::path& filename) { } // Do the file contain requested range? - if(end && end < begin || begin > length) { + if((end && end < begin) || begin > length) { send_error(416); } -- cgit v1.2.3