| 5167 | } |
| 5168 | |
| 5169 | inline bool Server::read_content(Stream &strm, Request &req, Response &res) { |
| 5170 | MultipartFormDataMap::iterator cur; |
| 5171 | if (read_content_core( |
| 5172 | strm, req, res, |
| 5173 | // Regular |
| 5174 | [&](const char *buf, size_t n) { |
| 5175 | if (req.body.size() + n > req.body.max_size()) { return false; } |
| 5176 | req.body.append(buf, n); |
| 5177 | return true; |
| 5178 | }, |
| 5179 | // Multipart |
| 5180 | [&](const MultipartFormData &file) { |
| 5181 | cur = req.files.emplace(file.name, file); |
| 5182 | return true; |
| 5183 | }, |
| 5184 | [&](const char *buf, size_t n) { |
| 5185 | auto &content = cur->second.content; |
| 5186 | if (content.size() + n > content.max_size()) { return false; } |
| 5187 | content.append(buf, n); |
| 5188 | return true; |
| 5189 | })) { |
| 5190 | const auto &content_type = req.get_header_value("Content-Type"); |
| 5191 | if (!content_type.find("application/x-www-form-urlencoded")) { |
| 5192 | if (req.body.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) { |
| 5193 | res.status = 413; // NOTE: should be 414? |
| 5194 | return false; |
| 5195 | } |
| 5196 | detail::parse_query_text(req.body, req.params); |
| 5197 | } |
| 5198 | return true; |
| 5199 | } |
| 5200 | return false; |
| 5201 | } |
| 5202 | |
| 5203 | inline bool Server::read_content_with_content_receiver( |
| 5204 | Stream &strm, Request &req, Response &res, ContentReceiver receiver, |
nothing calls this directly
no test coverage detected