httpgateway: set new max payload length config value
Dieser Commit ist enthalten in:
Ursprung
8fe7e98aaa
Commit
93aea9ed7b
13
config.cpp
13
config.cpp
@ -53,6 +53,17 @@ int Config::optional(const std::string &key, int defaultvalue)
|
||||
return defaultvalue;
|
||||
}
|
||||
|
||||
uint64_t Config::optional(const std::string &key, uint64_t defaultvalue)
|
||||
{
|
||||
auto it = this->configmap.find(key);
|
||||
if(it != this->configmap.end())
|
||||
{
|
||||
std::string str = it->second;
|
||||
return static_cast<uint64_t>(std::stoull(str));
|
||||
}
|
||||
return defaultvalue;
|
||||
}
|
||||
|
||||
Config::Config(const std::map<std::string, std::string> &map)
|
||||
{
|
||||
|
||||
@ -93,6 +104,8 @@ Config::Config(const std::map<std::string, std::string> &map)
|
||||
this->anon_permissions = Permissions(required("anon_permissions"));
|
||||
|
||||
this->templateprefix = "{qswiki:";
|
||||
|
||||
this->max_payload_length = optional("max_payload_length", 10 * 1024 * 1024);
|
||||
}
|
||||
|
||||
ConfigReader::ConfigReader(const std::string &file)
|
||||
|
4
config.h
4
config.h
@ -14,6 +14,7 @@ class Config
|
||||
|
||||
std::string optional(const std::string &key, std::string defaultvalue = "");
|
||||
int optional(const std::string &key, int defaulvalue);
|
||||
uint64_t optional(const std::string &key, uint64_t defaultvalue);
|
||||
|
||||
public:
|
||||
Config(const std::map<std::string, std::string> &map);
|
||||
@ -51,6 +52,9 @@ class Config
|
||||
int session_max_lifetime;
|
||||
int max_pagename_length;
|
||||
int threadscount;
|
||||
|
||||
uint64_t max_payload_length;
|
||||
|
||||
Permissions anon_permissions;
|
||||
|
||||
std::string getConfig(const std::string &key) const
|
||||
|
@ -33,6 +33,8 @@ HttpGateway::HttpGateway(const Config &config)
|
||||
throw new std::runtime_error("No http.listenport in config file");
|
||||
}
|
||||
this->listenport = std::stoi(listenport);
|
||||
|
||||
this->maxPayloadLength = config.max_payload_length;
|
||||
}
|
||||
|
||||
bool HttpGateway::keepReading()
|
||||
@ -90,7 +92,7 @@ httplib::Response HttpGateway::convertResponse(Response response)
|
||||
void HttpGateway::work(RequestWorker &worker)
|
||||
{
|
||||
httplib::Server server;
|
||||
|
||||
server.set_payload_max_length(this->maxPayloadLength);
|
||||
auto handler = [&](const httplib::Request &req, httplib::Response &res) {
|
||||
Request wikiRequest = convertRequest(req);
|
||||
Logger::debug() << "httpgateway: received request " << wikiRequest;
|
||||
|
@ -16,6 +16,7 @@ class HttpGateway : public GatewayInterface
|
||||
|
||||
std::string listenaddr;
|
||||
int listenport;
|
||||
uint64_t maxPayloadLength;
|
||||
|
||||
public:
|
||||
HttpGateway(const Config &config);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren