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

Function process_multipart_ranges_data

examples/server/httplib.h:4344–4376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4342
4343template <typename SToken, typename CToken, typename Content>
4344bool process_multipart_ranges_data(const Request &req, Response &res,
4345 const std::string &boundary,
4346 const std::string &content_type,
4347 SToken stoken, CToken ctoken,
4348 Content content) {
4349 for (size_t i = 0; i < req.ranges.size(); i++) {
4350 ctoken("--");
4351 stoken(boundary);
4352 ctoken("\r\n");
4353 if (!content_type.empty()) {
4354 ctoken("Content-Type: ");
4355 stoken(content_type);
4356 ctoken("\r\n");
4357 }
4358
4359 auto offsets = get_range_offset_and_length(req, res.body.size(), i);
4360 auto offset = offsets.first;
4361 auto length = offsets.second;
4362
4363 ctoken("Content-Range: ");
4364 stoken(make_content_range_header_field(offset, length, res.body.size()));
4365 ctoken("\r\n");
4366 ctoken("\r\n");
4367 if (!content(offset, length)) { return false; }
4368 ctoken("\r\n");
4369 }
4370
4371 ctoken("--");
4372 stoken(boundary);
4373 ctoken("--\r\n");
4374
4375 return true;
4376}
4377
4378inline bool make_multipart_ranges_data(const Request &req, Response &res,
4379 const std::string &boundary,

Callers 3

Calls 5

contentFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected