| 5521 | } |
| 5522 | |
| 5523 | inline bool |
| 5524 | Server::write_content_with_provider(Stream &strm, const Request &req, |
| 5525 | Response &res, const std::string &boundary, |
| 5526 | const std::string &content_type) { |
| 5527 | auto is_shutting_down = [this]() { |
| 5528 | return this->svr_sock_ == INVALID_SOCKET; |
| 5529 | }; |
| 5530 | |
| 5531 | if (res.content_length_ > 0) { |
| 5532 | if (req.ranges.empty()) { |
| 5533 | return detail::write_content(strm, res.content_provider_, 0, |
| 5534 | res.content_length_, is_shutting_down); |
| 5535 | } else if (req.ranges.size() == 1) { |
| 5536 | auto offsets = |
| 5537 | detail::get_range_offset_and_length(req, res.content_length_, 0); |
| 5538 | auto offset = offsets.first; |
| 5539 | auto length = offsets.second; |
| 5540 | return detail::write_content(strm, res.content_provider_, offset, length, |
| 5541 | is_shutting_down); |
| 5542 | } else { |
| 5543 | return detail::write_multipart_ranges_data( |
| 5544 | strm, req, res, boundary, content_type, is_shutting_down); |
| 5545 | } |
| 5546 | } else { |
| 5547 | if (res.is_chunked_content_provider_) { |
| 5548 | auto type = detail::encoding_type(req, res); |
| 5549 | |
| 5550 | std::unique_ptr<detail::compressor> compressor; |
| 5551 | if (type == detail::EncodingType::Gzip) { |
| 5552 | #ifdef CPPHTTPLIB_ZLIB_SUPPORT |
| 5553 | compressor = detail::make_unique<detail::gzip_compressor>(); |
| 5554 | #endif |
| 5555 | } else if (type == detail::EncodingType::Brotli) { |
| 5556 | #ifdef CPPHTTPLIB_BROTLI_SUPPORT |
| 5557 | compressor = detail::make_unique<detail::brotli_compressor>(); |
| 5558 | #endif |
| 5559 | } else { |
| 5560 | compressor = detail::make_unique<detail::nocompressor>(); |
| 5561 | } |
| 5562 | assert(compressor != nullptr); |
| 5563 | |
| 5564 | return detail::write_content_chunked(strm, res.content_provider_, |
| 5565 | is_shutting_down, *compressor); |
| 5566 | } else { |
| 5567 | return detail::write_content_without_length(strm, res.content_provider_, |
| 5568 | is_shutting_down); |
| 5569 | } |
| 5570 | } |
| 5571 | } |
| 5572 | |
| 5573 | inline bool Server::read_content(Stream &strm, Request &req, Response &res) { |
| 5574 | MultipartFormDataMap::iterator cur; |
nothing calls this directly
no test coverage detected