http server options, remove old

This commit is contained in:
2024-11-15 14:18:49 +03:00
parent cdde340efe
commit ee137b2820
5 changed files with 70 additions and 52 deletions

View File

@@ -132,9 +132,7 @@ inline void piSwapBinary(const void *& f, const void *& s) {
//! \~english Example:\n \snippet piincludes.cpp compareBinary
//! \~russian Пример:\n \snippet piincludes.cpp compareBinary
inline bool piCompareBinary(const void * f, const void * s, size_t size) {
for (size_t i = 0; i < size; ++i)
if (((const uchar *)f)[i] != ((const uchar *)s)[i]) return false;
return true;
return 0 == memcmp(f, s, size);
}
//! \~\brief

View File

@@ -27,6 +27,14 @@ public:
Trace,
Patch
};
enum class Option {
ConnectionLimit, // uint
ConnectionTimeout, // uint, sec
HTTPSEnabled, // bool
HTTPSMemKey, // const char * to key.pem data
HTTPSMemCert, // const char * to cert.pem data
HTTPSKeyPassword // const char * to passwd for key.pem
};
struct PIP_HTTP_SERVER_EXPORT Request {
MicrohttpdServer::Method method;
@@ -52,7 +60,7 @@ public:
PIMap<PIString, PIString> headers;
};
void setWWWRoot(const PIString & path);
void setOption(Option o, PIVariant v);
void setFavicon(const PIByteArray & im);
bool listen(PINetworkAddress addr);
@@ -63,12 +71,12 @@ public:
void setRequestCallback(std::function<Reply(Request)> c) { callback = c; }
private:
PIByteArray getFile(PIString name);
PRIVATE_DECLARATION(PIP_HTTP_SERVER_EXPORT)
PIString www_root;
PIByteArray favicon;
PIMap<Option, PIVariant> opts;
std::function<Reply(Request)> callback;
PIByteArray mem_key, mem_cert, key_pass;
};