bool RequestParser::IsBoundary(const std::string& str, std::size_t off,
                               std::size_t count, bool* end) const {
  const std::string& boundary = content_type_.boundary();

  if (count != boundary.size() + 2 && count != boundary.size() + 4) {
    return false;
  }

  if (str[off] != '-' || str[off + 1] != '-') {
    return false;
  }

  if (count == boundary.size() + 4) {
    if (str[off + count - 1] != '-' || str[off + count - 2] != '-') {
      return false;
    }
    if (end != nullptr) {
      *end = true;
    }
  }

  return strncmp(boundary.c_str(), &str[off + 2], boundary.size()) == 0;
}
bool RequestParser::IsBoundary(const std::string& str, std::size_t off,
                               std::size_t count, bool* end) const {
  const std::string& boundary = content_type_.boundary();

  if (count != boundary.size() + 2 && count != boundary.size() + 4) {
    return false;
  }

  if (str[off] != '-' || str[off + 1] != '-') {
    return false;
  }

  if (count == boundary.size() + 4) {
    if (str[off + count - 1] != '-' || str[off + count - 2] != '-') {
      return false;
    }
    if (end != nullptr) {
      *end = true;
    }
  }

  return strncmp(boundary.c_str(), &str[off + 2], boundary.size()) == 0;
}