blob: 5f1780a8f4e55bc87887ada152791f2873f5b8c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<%pre>
#include <string>
#include <tnt/httperror.h>
#include <tnt/httpheader.h>
#include "filecache.h"
#include "setup.h"
using namespace std;
using namespace vdrlive;
</%pre>
<%session scope="global">
bool logged_in(false);
</%session>
<%cpp>
//if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
string mime("image/png");
if (request.getArgsCount() > 0) {
mime = request.getArg(0);
// dsyslog("vdrlive::content found mime arg (%s)", mime.c_str());
}
reply.setContentType(mime);
// dsyslog("vdrlive::content::mimetype(%s)", mime.c_str());
// FileCache::ptr_type f = LiveFileCache().get("/tmp/live/" + request.getPathInfo());
string const path(request.getPathInfo());
FileCache::ptr_type f;
string const epgImgPath(LiveSetup().GetEpgImageDir());
if (!epgImgPath.empty() && path.find(epgImgPath) != string::npos) {
f = LiveFileCache().get(path);
}
else {
f = LiveFileCache().get(Plugin::GetConfigDirectory() + "/" + path);
}
if (f.get() == 0) {
return DECLINED;
}
string ctime = tnt::HttpMessage::htdate(f->ctime());
string browserTime = request.getHeader(tnt::httpheader::ifModifiedSince);
if (browserTime == ctime)
return HTTP_NOT_MODIFIED;
reply.setHeader(tnt::httpheader::lastModified, ctime);
reply.out().write(f->data(), f->size());
</%cpp>
|