Loading editor/config.yaml +1 −0 Changes for editor/config.yaml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ WEBEDIT: BIND: "0.0.0.0" PORT: 8090 MAXCON: 256 MAXVERSION: "HTTP/2" SSL: CERT: "" KEY: "" Loading editor/src/webedit_config.cpp +20 −0 Changes for editor/src/webedit_config.cpp: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -45,6 +45,26 @@ webedit::Config::Config(const std::string &path) : confplus::Config(path) { _httpMaxCon = 256; } try { _httpMaxVersion = getValue(getKey("/WEBEDIT/HTTP/MAXVERSION"), 0); } catch (...) { try { // Backward compatibility with older config key. _httpMaxVersion = getValue(getKey("/WEBEDIT/HTTP/VERSION"), 0); } catch (...) { _httpMaxVersion = "HTTP/2"; } } for (auto &c : _httpMaxVersion) c = std::toupper(static_cast<unsigned char>(c)); if (_httpMaxVersion == "1" || _httpMaxVersion == "HTTP/1" || _httpMaxVersion == "HTTP/1.1" || _httpMaxVersion == "HTTP1" || _httpMaxVersion == "HTTP1.1") _httpMaxVersion = "HTTP/1.1"; else if (_httpMaxVersion == "2" || _httpMaxVersion == "H2" || _httpMaxVersion == "HTTP2") _httpMaxVersion = "HTTP/2"; else if (_httpMaxVersion == "3" || _httpMaxVersion == "H3" || _httpMaxVersion == "HTTP3") _httpMaxVersion = "HTTP/3"; else if (_httpMaxVersion != "HTTP/1.1" && _httpMaxVersion != "HTTP/2" && _httpMaxVersion != "HTTP/3") _httpMaxVersion = "HTTP/2"; try { _sslCert = getValue(getKey("/WEBEDIT/SSL/CERT"), 0); } catch (...) {} Loading editor/src/webedit_config.h +2 −0 Changes for editor/src/webedit_config.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ namespace webedit { const std::string &getHttpBind() const { return _httpBind; } int getHttpPort() const { return _httpPort; } int getHttpMaxCon() const { return _httpMaxCon; } const std::string &getHttpMaxVersion() const { return _httpMaxVersion; } const std::string &getSslCert() const { return _sslCert; } const std::string &getSslKey() const { return _sslKey; } Loading @@ -65,6 +66,7 @@ namespace webedit { std::string _httpBind; int _httpPort; int _httpMaxCon; std::string _httpMaxVersion; std::string _sslCert; std::string _sslKey; Loading editor/src/webedit_server.cpp +19 −0 Changes for editor/src/webedit_server.cpp: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -82,6 +82,25 @@ std::string webedit::Server::getCookie(libhttppp::HttpRequest &curreq, void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, const int tid, ULONG_PTR args) { try { auto versionRank = [](const std::string &v) -> int { if (v == "HTTP/1.0" || v == "HTTP/1.1") return 1; if (v == "HTTP/2") return 2; if (v == "HTTP/3") return 3; return 0; }; const std::string &reqVersion = curreq.getRequestVersion(); const int reqRank = versionRank(reqVersion); const int maxRank = versionRank(_config.getHttpMaxVersion()); if (reqRank == 0 || maxRank == 0 || reqRank > maxRank) { libhttppp::HttpResponse resp; resp.setState(HTTP505); resp.setContentType("application/json"); const char *err = "{\"error\":\"HTTP version not supported by server policy\"}"; resp.send(curreq, err, strlen(err)); return; } std::string url = curreq.getRequestURL(); std::string prefix = _config.getPrefix(); Loading Loading
editor/config.yaml +1 −0 Changes for editor/config.yaml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ WEBEDIT: BIND: "0.0.0.0" PORT: 8090 MAXCON: 256 MAXVERSION: "HTTP/2" SSL: CERT: "" KEY: "" Loading
editor/src/webedit_config.cpp +20 −0 Changes for editor/src/webedit_config.cpp: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -45,6 +45,26 @@ webedit::Config::Config(const std::string &path) : confplus::Config(path) { _httpMaxCon = 256; } try { _httpMaxVersion = getValue(getKey("/WEBEDIT/HTTP/MAXVERSION"), 0); } catch (...) { try { // Backward compatibility with older config key. _httpMaxVersion = getValue(getKey("/WEBEDIT/HTTP/VERSION"), 0); } catch (...) { _httpMaxVersion = "HTTP/2"; } } for (auto &c : _httpMaxVersion) c = std::toupper(static_cast<unsigned char>(c)); if (_httpMaxVersion == "1" || _httpMaxVersion == "HTTP/1" || _httpMaxVersion == "HTTP/1.1" || _httpMaxVersion == "HTTP1" || _httpMaxVersion == "HTTP1.1") _httpMaxVersion = "HTTP/1.1"; else if (_httpMaxVersion == "2" || _httpMaxVersion == "H2" || _httpMaxVersion == "HTTP2") _httpMaxVersion = "HTTP/2"; else if (_httpMaxVersion == "3" || _httpMaxVersion == "H3" || _httpMaxVersion == "HTTP3") _httpMaxVersion = "HTTP/3"; else if (_httpMaxVersion != "HTTP/1.1" && _httpMaxVersion != "HTTP/2" && _httpMaxVersion != "HTTP/3") _httpMaxVersion = "HTTP/2"; try { _sslCert = getValue(getKey("/WEBEDIT/SSL/CERT"), 0); } catch (...) {} Loading
editor/src/webedit_config.h +2 −0 Changes for editor/src/webedit_config.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ namespace webedit { const std::string &getHttpBind() const { return _httpBind; } int getHttpPort() const { return _httpPort; } int getHttpMaxCon() const { return _httpMaxCon; } const std::string &getHttpMaxVersion() const { return _httpMaxVersion; } const std::string &getSslCert() const { return _sslCert; } const std::string &getSslKey() const { return _sslKey; } Loading @@ -65,6 +66,7 @@ namespace webedit { std::string _httpBind; int _httpPort; int _httpMaxCon; std::string _httpMaxVersion; std::string _sslCert; std::string _sslKey; Loading
editor/src/webedit_server.cpp +19 −0 Changes for editor/src/webedit_server.cpp: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -82,6 +82,25 @@ std::string webedit::Server::getCookie(libhttppp::HttpRequest &curreq, void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, const int tid, ULONG_PTR args) { try { auto versionRank = [](const std::string &v) -> int { if (v == "HTTP/1.0" || v == "HTTP/1.1") return 1; if (v == "HTTP/2") return 2; if (v == "HTTP/3") return 3; return 0; }; const std::string &reqVersion = curreq.getRequestVersion(); const int reqRank = versionRank(reqVersion); const int maxRank = versionRank(_config.getHttpMaxVersion()); if (reqRank == 0 || maxRank == 0 || reqRank > maxRank) { libhttppp::HttpResponse resp; resp.setState(HTTP505); resp.setContentType("application/json"); const char *err = "{\"error\":\"HTTP version not supported by server policy\"}"; resp.send(curreq, err, strlen(err)); return; } std::string url = curreq.getRequestURL(); std::string prefix = _config.getPrefix(); Loading