summaryrefslogtreecommitdiff
path: root/http_connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'http_connection.cpp')
-rw-r--r--http_connection.cpp7
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);
}