summaryrefslogtreecommitdiff
path: root/http_connection.cpp
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-03-03 12:33:05 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2011-03-03 12:33:05 +0100
commit3568ebefab593ba03f3d874d5b2e130aec4f1a89 (patch)
treedaa5491b4a0c10be9d0a96a0bbb6c9a6a6af340c /http_connection.cpp
parentdd62185d31b2967a98a1fa58bf869db46ab8284b (diff)
Fixed content-type and range handling.
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);
}