diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-03-03 12:33:05 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-03-03 12:33:05 +0100 |
commit | 3568ebefab593ba03f3d874d5b2e130aec4f1a89 (patch) | |
tree | daa5491b4a0c10be9d0a96a0bbb6c9a6a6af340c /http_connection.cpp | |
parent | dd62185d31b2967a98a1fa58bf869db46ab8284b (diff) |
Fixed content-type and range handling.
Diffstat (limited to 'http_connection.cpp')
-rw-r--r-- | http_connection.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
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<int>(std::string(range_str.begin(), it)); - std::size_t end = boost::lexical_cast<int>(std::string(it + 1, range_str.end())) + 1; + std::size_t end = length; + if(++it != range_str.end()) { + end = boost::lexical_cast<int>(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); } |