MythTV  master
mythhttproot.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythdirs.h"
3 #include "http/mythhttproot.h"
4 #include "http/mythhttpdata.h"
5 #include "http/mythhttpfile.h"
6 #include "http/mythhttprequest.h"
8 
9 #define INDEX QStringLiteral("index.html")
10 
25 {
26  auto result = static_cast<HTTPResponse>(nullptr);
27  if (!Request)
28  return result;
29 
30  // this is the top level handler. We deal with the empty root request
31  // and index.html
32  if (Request->m_fileName.isEmpty())
33  Request->m_fileName = INDEX;
34  if (Request->m_fileName != INDEX)
35  return result;
37 
39  if (result)
40  return result;
41 
42  if (!File.isEmpty())
43  {
44  Request->m_fileName = File;
46  // Rename the file
47  if (auto * file = std::get_if<HTTPFile>(&result->m_response))
48  (*file)->m_fileName = INDEX;
49  }
50  else
51  {
52  auto data = MythHTTPData::Create("index.html", s_defaultHTTPPage.arg("MythTV").toUtf8().constData());
54  }
55  return result;
56 
57 }
MythHTTPResponse::DataResponse
static HTTPResponse DataResponse(const HTTPRequest2 &Request, const HTTPData &Data)
Definition: mythhttpresponse.cpp:262
HTTPPut
@ HTTPPut
Definition: mythhttptypes.h:95
HTTP_DEFAULT_ALLOWED
#define HTTP_DEFAULT_ALLOWED
Definition: mythhttptypes.h:102
build_compdb.file
file
Definition: build_compdb.py:55
mythdirs.h
mythhttpdata.h
mythhttpfile.h
MythHTTPResponse::HandleOptions
static HTTPResponse HandleOptions(const HTTPRequest2 &Request)
Definition: mythhttpresponse.cpp:192
MythHTTPFile::ProcessFile
static HTTPResponse ProcessFile(const HTTPRequest2 &Request)
Definition: mythhttpfile.cpp:35
MythHTTPData::Create
static HTTPData Create()
Definition: mythhttpdata.cpp:4
HTTPDelete
@ HTTPDelete
Definition: mythhttptypes.h:96
s_defaultHTTPPage
static QString s_defaultHTTPPage
Definition: mythhttptypes.h:153
mythhttpresponse.h
MythHTTPRoot::RedirectRoot
static HTTPResponse RedirectRoot(const HTTPRequest2 &Request, const QString &File)
A convenience method to seemlessly redirect requests for index.html to a context specific file.
Definition: mythhttproot.cpp:24
HTTPResponse
std::shared_ptr< MythHTTPResponse > HTTPResponse
Definition: mythhttptypes.h:39
hardwareprofile.distros.mythtv_data.request.Request
def Request(url=None)
Definition: distros/mythtv_data/request.py:62
INDEX
#define INDEX
Definition: mythhttproot.cpp:9
mythhttproot.h
HTTPRequest2
std::shared_ptr< MythHTTPRequest > HTTPRequest2
Definition: mythhttptypes.h:38
mythhttprequest.h