MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / read_content

Method read_content

examples/server/httplib.h:5573–5609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5571}
5572
5573inline bool Server::read_content(Stream &strm, Request &req, Response &res) {
5574 MultipartFormDataMap::iterator cur;
5575 auto file_count = 0;
5576 if (read_content_core(
5577 strm, req, res,
5578 // Regular
5579 [&](const char *buf, size_t n) {
5580 if (req.body.size() + n > req.body.max_size()) { return false; }
5581 req.body.append(buf, n);
5582 return true;
5583 },
5584 // Multipart
5585 [&](const MultipartFormData &file) {
5586 if (file_count++ == CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT) {
5587 return false;
5588 }
5589 cur = req.files.emplace(file.name, file);
5590 return true;
5591 },
5592 [&](const char *buf, size_t n) {
5593 auto &content = cur->second.content;
5594 if (content.size() + n > content.max_size()) { return false; }
5595 content.append(buf, n);
5596 return true;
5597 })) {
5598 const auto &content_type = req.get_header_value("Content-Type");
5599 if (!content_type.find("application/x-www-form-urlencoded")) {
5600 if (req.body.size() > CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH) {
5601 res.status = 413; // NOTE: should be 414?
5602 return false;
5603 }
5604 detail::parse_query_text(req.body, req.params);
5605 }
5606 return true;
5607 }
5608 return false;
5609}
5610
5611inline bool Server::read_content_with_content_receiver(
5612 Stream &strm, Request &req, Response &res, ContentReceiver receiver,

Callers

nothing calls this directly

Calls 6

parse_query_textFunction · 0.85
get_header_valueMethod · 0.80
findMethod · 0.80
sizeMethod · 0.45
max_sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected