void set_status_and_content_view()

in include/ylt/standalone/cinatra/coro_http_response.hpp [65:159]


  void set_status_and_content_view(
      status_type status, String content = "",
      content_encoding encoding = content_encoding::none, bool is_view = true,
      std::string_view client_encoding_type = "") {
    status_ = status;
#ifdef CINATRA_ENABLE_GZIP
    if (encoding == content_encoding::gzip) {
      if (client_encoding_type.empty() ||
          client_encoding_type.find("gzip") != std::string_view::npos) {
        std::string encode_str;
        bool r = gzip_codec::compress(content, encode_str);
        if (!r) {
          set_status_and_content(status_type::internal_server_error,
                                 "gzip compress error");
        }
        else {
          add_header("Content-Encoding", "gzip");
          set_content(std::move(encode_str));
        }
      }
      else {
        if (is_view) {
          content_view_ = content;
        }
        else {
          content_ = std::move(content);
        }
      }
      has_set_content_ = true;
      return;
    }

    if (encoding == content_encoding::deflate) {
      if (client_encoding_type.empty() ||
          client_encoding_type.find("deflate") != std::string_view::npos) {
        std::string deflate_str;
        bool r = gzip_codec::deflate(content, deflate_str);
        if (!r) {
          set_status_and_content(status_type::internal_server_error,
                                 "deflate compress error");
        }
        else {
          add_header("Content-Encoding", "deflate");
          set_content(std::move(deflate_str));
        }
      }
      else {
        if (is_view) {
          content_view_ = content;
        }
        else {
          content_ = std::move(content);
        }
      }
      has_set_content_ = true;
      return;
    }
#endif

#ifdef CINATRA_ENABLE_BROTLI
    if (encoding == content_encoding::br) {
      if (client_encoding_type.empty() ||
          client_encoding_type.find("br") != std::string_view::npos) {
        std::string br_str;
        bool r = br_codec::brotli_compress(content, br_str);
        if (!r) {
          set_status_and_content(status_type::internal_server_error,
                                 "br compress error");
        }
        else {
          add_header("Content-Encoding", "br");
          set_content(std::move(br_str));
        }
      }
      else {
        if (is_view) {
          content_view_ = content;
        }
        else {
          content_ = std::move(content);
        }
      }
      has_set_content_ = true;
      return;
    }
#endif

    if (is_view) {
      content_view_ = content;
    }
    else {
      content_ = std::move(content);
    }
    has_set_content_ = true;
  }