MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / read_content_core

Method read_content_core

dependencies/httplib/httplib.h:5212–5265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5210}
5211
5212inline bool Server::read_content_core(Stream &strm, Request &req, Response &res,
5213 ContentReceiver receiver,
5214 MultipartContentHeader mulitpart_header,
5215 ContentReceiver multipart_receiver) {
5216 detail::MultipartFormDataParser multipart_form_data_parser;
5217 ContentReceiverWithProgress out;
5218
5219 if (req.is_multipart_form_data()) {
5220 const auto &content_type = req.get_header_value("Content-Type");
5221 std::string boundary;
5222 if (!detail::parse_multipart_boundary(content_type, boundary)) {
5223 res.status = 400;
5224 return false;
5225 }
5226
5227 multipart_form_data_parser.set_boundary(std::move(boundary));
5228 out = [&](const char *buf, size_t n, uint64_t /*off*/, uint64_t /*len*/) {
5229 /* For debug
5230 size_t pos = 0;
5231 while (pos < n) {
5232 auto read_size = (std::min)<size_t>(1, n - pos);
5233 auto ret = multipart_form_data_parser.parse(
5234 buf + pos, read_size, multipart_receiver, mulitpart_header);
5235 if (!ret) { return false; }
5236 pos += read_size;
5237 }
5238 return true;
5239 */
5240 return multipart_form_data_parser.parse(buf, n, multipart_receiver,
5241 mulitpart_header);
5242 };
5243 } else {
5244 out = [receiver](const char *buf, size_t n, uint64_t /*off*/,
5245 uint64_t /*len*/) { return receiver(buf, n); };
5246 }
5247
5248 if (req.method == "DELETE" && !req.has_header("Content-Length")) {
5249 return true;
5250 }
5251
5252 if (!detail::read_content(strm, req, payload_max_length_, res.status, nullptr,
5253 out, true)) {
5254 return false;
5255 }
5256
5257 if (req.is_multipart_form_data()) {
5258 if (!multipart_form_data_parser.is_valid()) {
5259 res.status = 400;
5260 return false;
5261 }
5262 }
5263
5264 return true;
5265}
5266
5267inline bool Server::handle_file_request(const Request &req, Response &res,
5268 bool head) {

Callers

nothing calls this directly

Calls 8

parse_multipart_boundaryFunction · 0.85
read_contentFunction · 0.85
get_header_valueMethod · 0.80
set_boundaryMethod · 0.80
has_headerMethod · 0.80
parseMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected