📄 httpsvc.h
字号:
PTime compilationDate;
PString manufacturersHomePage;
PString manufacturersEmail;
PString productNameHTML;
PString gifHTML;
PString copyrightHolder;
PString copyrightHomePage;
PString copyrightEmail;
void ShutdownListener();
void BeginRestartSystem();
void CompleteRestartSystem();
PThread * restartThread;
PLIST(ThreadList, PHTTPServiceThread);
ThreadList httpThreads;
PMutex httpThreadsMutex;
friend class PConfigPage;
friend class PConfigSectionsPage;
friend class PHTTPServiceThread;
};
/////////////////////////////////////////////////////////////////////
class PConfigPage : public PHTTPConfig
{
PCLASSINFO(PConfigPage, PHTTPConfig)
public:
PConfigPage(
PHTTPServiceProcess & app,
const PString & section,
const PHTTPAuthority & auth
);
PConfigPage(
PHTTPServiceProcess & app,
const PString & title,
const PString & section,
const PHTTPAuthority & auth
);
void OnLoadedText(PHTTPRequest &, PString & text);
BOOL OnPOST(
PHTTPServer & server,
const PURL & url,
const PMIMEInfo & info,
const PStringToString & data,
const PHTTPConnectionInfo & connectInfo
);
virtual BOOL Post(
PHTTPRequest & request, ///< Information on this request.
const PStringToString & data, ///< Variables in the POST data.
PHTML & replyMessage ///< Reply message for post.
);
protected:
virtual BOOL GetExpirationDate(
PTime & when ///< Time that the resource expires
);
PHTTPServiceProcess & process;
};
/////////////////////////////////////////////////////////////////////
class PConfigSectionsPage : public PHTTPConfigSectionList
{
PCLASSINFO(PConfigSectionsPage, PHTTPConfigSectionList)
public:
PConfigSectionsPage(
PHTTPServiceProcess & app,
const PURL & url,
const PHTTPAuthority & auth,
const PString & prefix,
const PString & valueName,
const PURL & editSection,
const PURL & newSection,
const PString & newTitle,
PHTML & heading
);
void OnLoadedText(PHTTPRequest &, PString & text);
BOOL OnPOST(
PHTTPServer & server,
const PURL & url,
const PMIMEInfo & info,
const PStringToString & data,
const PHTTPConnectionInfo & connectInfo
);
virtual BOOL Post(
PHTTPRequest & request, ///< Information on this request.
const PStringToString & data, ///< Variables in the POST data.
PHTML & replyMessage ///< Reply message for post.
);
protected:
virtual BOOL GetExpirationDate(
PTime & when ///< Time that the resource expires
);
PHTTPServiceProcess & process;
};
/////////////////////////////////////////////////////////////////////
class PRegisterPage : public PConfigPage
{
PCLASSINFO(PRegisterPage, PConfigPage)
public:
PRegisterPage(
PHTTPServiceProcess & app,
const PHTTPAuthority & auth
);
PString LoadText(
PHTTPRequest & request ///< Information on this request.
);
void OnLoadedText(PHTTPRequest & request, PString & text);
virtual BOOL Post(
PHTTPRequest & request, ///< Information on this request.
const PStringToString & data, ///< Variables in the POST data.
PHTML & replyMessage ///< Reply message for post.
);
virtual void AddFields(
const PString & prefix ///< Prefix on field names
) = 0;
protected:
PHTTPServiceProcess & process;
};
/////////////////////////////////////////////////////////////////////S
class PServiceHTML : public PHTML
{
PCLASSINFO(PServiceHTML, PHTML)
public:
PServiceHTML(const char * title,
const char * help = NULL,
const char * helpGif = "help.gif");
PString ExtractSignature(PString & out);
static PString ExtractSignature(const PString & html,
PString & out,
const char * keyword = "#equival");
PString CalculateSignature();
static PString CalculateSignature(const PString & out);
static PString CalculateSignature(const PString & out, const PTEACypher::Key & sig);
BOOL CheckSignature();
static BOOL CheckSignature(const PString & html);
enum MacroOptions {
NoOptions = 0,
NeedSignature = 1,
LoadFromFile = 2,
NoURLOverride = 4,
NoSignatureForFile = 8
};
static BOOL ProcessMacros(PHTTPRequest & request,
PString & text,
const PString & filename,
unsigned options);
};
///////////////////////////////////////////////////////////////
class PServiceMacro : public PObject
{
public:
PServiceMacro(const char * name, BOOL isBlock);
PServiceMacro(const PCaselessString & name, BOOL isBlock);
Comparison Compare(const PObject & obj) const;
virtual PString Translate(
PHTTPRequest & request,
const PString & args,
const PString & block
) const;
protected:
const char * macroName;
BOOL isMacroBlock;
PServiceMacro * link;
static PServiceMacro * list;
friend class PServiceMacros_list;
};
#define P_EMPTY
#define PCREATE_SERVICE_MACRO(name, request, args) \
class PServiceMacro_##name : public PServiceMacro { \
public: \
PServiceMacro_##name() : PServiceMacro(#name, FALSE) { } \
PString Translate(PHTTPRequest &, const PString &, const PString &) const; \
}; \
static const PServiceMacro_##name serviceMacro_##name; \
PString PServiceMacro_##name::Translate(PHTTPRequest & request, const PString & args, const PString &) const
#define PCREATE_SERVICE_MACRO_BLOCK(name, request, args, block) \
class PServiceMacro_##name : public PServiceMacro { \
public: \
PServiceMacro_##name() : PServiceMacro(#name, TRUE) { } \
PString Translate(PHTTPRequest &, const PString &, const PString &) const; \
}; \
static const PServiceMacro_##name serviceMacro_##name; \
PString PServiceMacro_##name::Translate(PHTTPRequest & request, const PString & args, const PString & block) const
///////////////////////////////////////////////////////////////
class PServiceHTTPString : public PHTTPString
{
PCLASSINFO(PServiceHTTPString, PHTTPString)
public:
PServiceHTTPString(const PURL & url, const PString & string)
: PHTTPString(url, string) { }
PServiceHTTPString(const PURL & url, const PHTTPAuthority & auth)
: PHTTPString(url, auth) { }
PServiceHTTPString(const PURL & url, const PString & string, const PHTTPAuthority & auth)
: PHTTPString(url, string, auth) { }
PServiceHTTPString(const PURL & url, const PString & string, const PString & contentType)
: PHTTPString(url, string, contentType) { }
PServiceHTTPString(const PURL & url, const PString & string, const PString & contentType, const PHTTPAuthority & auth)
: PHTTPString(url, string, contentType, auth) { }
PString LoadText(PHTTPRequest &);
protected:
virtual BOOL GetExpirationDate(
PTime & when ///< Time that the resource expires
);
};
class PServiceHTTPFile : public PHTTPFile
{
PCLASSINFO(PServiceHTTPFile, PHTTPFile)
public:
PServiceHTTPFile(const PString & filename, BOOL needSig = FALSE)
: PHTTPFile(filename) { needSignature = needSig; }
PServiceHTTPFile(const PString & filename, const PFilePath & file, BOOL needSig = FALSE)
: PHTTPFile(filename, file) { needSignature = needSig; }
PServiceHTTPFile(const PString & filename, const PHTTPAuthority & auth, BOOL needSig = FALSE)
: PHTTPFile(filename, auth) { needSignature = needSig; }
PServiceHTTPFile(const PString & filename, const PFilePath & file, const PHTTPAuthority & auth, BOOL needSig = FALSE)
: PHTTPFile(filename, file, auth) { needSignature = needSig; }
void OnLoadedText(PHTTPRequest &, PString & text);
protected:
virtual BOOL GetExpirationDate(
PTime & when ///< Time that the resource expires
);
BOOL needSignature;
};
class PServiceHTTPDirectory : public PHTTPDirectory
{
PCLASSINFO(PServiceHTTPDirectory, PHTTPDirectory)
public:
PServiceHTTPDirectory(const PURL & url, const PDirectory & dirname, BOOL needSig = FALSE)
: PHTTPDirectory(url, dirname) { needSignature = needSig; }
PServiceHTTPDirectory(const PURL & url, const PDirectory & dirname, const PHTTPAuthority & auth, BOOL needSig = FALSE)
: PHTTPDirectory(url, dirname, auth) { needSignature = needSig; }
void OnLoadedText(PHTTPRequest &, PString & text);
protected:
virtual BOOL GetExpirationDate(
PTime & when ///< Time that the resource expires
);
BOOL needSignature;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -