Added CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH

This commit is contained in:
yhirose 2022-05-26 10:16:32 -04:00
parent 47044c05a8
commit 4001637beb

View file

@ -74,6 +74,10 @@
#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH ((std::numeric_limits<size_t>::max)()) #define CPPHTTPLIB_PAYLOAD_MAX_LENGTH ((std::numeric_limits<size_t>::max)())
#endif #endif
#ifndef CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH
#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH 8192
#endif
#ifndef CPPHTTPLIB_TCP_NODELAY #ifndef CPPHTTPLIB_TCP_NODELAY
#define CPPHTTPLIB_TCP_NODELAY false #define CPPHTTPLIB_TCP_NODELAY false
#endif #endif
@ -5189,7 +5193,7 @@ inline bool Server::read_content(Stream &strm, Request &req, Response &res) {
})) { })) {
const auto &content_type = req.get_header_value("Content-Type"); const auto &content_type = req.get_header_value("Content-Type");
if (!content_type.find("application/x-www-form-urlencoded")) { if (!content_type.find("application/x-www-form-urlencoded")) {
if (req.body.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) { if (req.body.size() > CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH) {
res.status = 413; // NOTE: should be 414? res.status = 413; // NOTE: should be 414?
return false; return false;
} }