summaryrefslogtreecommitdiff
path: root/httptnt
diff options
context:
space:
mode:
authormethodus <methodus@web.de>2012-10-22 01:27:07 +0200
committermethodus <methodus@web.de>2012-10-22 01:27:07 +0200
commitb419a39697be8257dfbdf26116ea022adf0da2e8 (patch)
tree6e94c1021aeefa23f0d182dc77fdbd907dd69ad5 /httptnt
parent9709cd3325c3bc85013e3835324ce2bdeead3f51 (diff)
downloadvdr-plugin-upnp-b419a39697be8257dfbdf26116ea022adf0da2e8.tar.gz
vdr-plugin-upnp-b419a39697be8257dfbdf26116ea022adf0da2e8.tar.bz2
Further improvements to make seeking possible.
Diffstat (limited to 'httptnt')
-rw-r--r--httptnt/resourceStreamer.ecpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/httptnt/resourceStreamer.ecpp b/httptnt/resourceStreamer.ecpp
index f064c49..9fddecc 100644
--- a/httptnt/resourceStreamer.ecpp
+++ b/httptnt/resourceStreamer.ecpp
@@ -64,11 +64,11 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object
length = to - from;
hasRange = true;
- if(request.isMethodHEAD()){
- std::stringstream contentRangeHeader;
- contentRangeHeader << "bytes " << from << "-" << to << "/" << contentLength;
- reply.setHeader("Content-Range ", contentRangeHeader.str());
- }
+ std::stringstream contentRangeHeader;
+ contentRangeHeader << "bytes " << from << "-" << to << "/" << contentLength;
+ reply.setHeader("Content-Range ", contentRangeHeader.str());
+ reply.setContentLengthHeader(length);
+
}
}
}
@@ -76,46 +76,28 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object
}
if(!request.isMethodHEAD()){
-
if(!streamer->Open()){
code = HTTP_INTERNAL_SERVER_ERROR;
goto ret;
}
- ssize_t bytesRead = 0;
-
if(hasRange && streamer->Seekable() && contentLength > 0){
-
if(!streamer->Seek(from, SEEK_SET)){
code = HTTP_INTERNAL_SERVER_ERROR;
goto close;
}
+ code = HTTP_PARTIAL_CONTENT;
+ }
- if(length > MB(1)) length = MB(1);
-
- char buffer[length];
- if((bytesRead = streamer->Read(buffer, length)) > 0){
- std::stringstream ss;
- ss << "bytes " << from << "-" << from + bytesRead << "/" << contentLength;
- reply.setHeader("Content-Range ", ss.str());
- reply.setContentLengthHeader(bytesRead);
- code = HTTP_PARTIAL_CONTENT;
- reply.out().write(buffer, bytesRead);
- if (!reply.out()) {
- code = HTTP_GONE;
- goto close;
- }
- }
-
- } else {
- reply.setDirectMode();
- char buffer[KB(20)];
- while ((bytesRead = streamer->Read(buffer, KB(20))) > 0) {
- reply.out().write(buffer, bytesRead);
- if (!reply.out()) {
- code = HTTP_GONE;
- goto close;
- }
+ reply.setDirectMode(code);
+
+ ssize_t bytesRead = 0;
+ char buffer[KB(20)];
+ while ((bytesRead = streamer->Read(buffer, KB(20))) > 0) {
+ reply.out().write(buffer, bytesRead);
+ if (!reply.out()) {
+ code = HTTP_GONE;
+ goto close;
}
}
} else {