void ResponseEncoderImpl::encodeHeaders(const ResponseHeaderMap& headers, bool end_stream) {
  started_response_ = true;

  // The contract is that client codecs must ensure that :status is present.
  ASSERT(headers.Status() != nullptr);
  uint64_t numeric_status = Utility::getResponseStatus(headers);

  absl::string_view response_prefix;
  if (connection_.protocol() == Protocol::Http10 && connection_.supportsHttp10()) {
    response_prefix = HTTP_10_RESPONSE_PREFIX;
  } else {
    response_prefix = RESPONSE_PREFIX;
  }

  StatefulHeaderKeyFormatterOptConstRef formatter(headers.formatter());

  absl::string_view reason_phrase;
  if (formatter.has_value() && !formatter->getReasonPhrase().empty()) {
    reason_phrase = formatter->getReasonPhrase();
  } else {
    const char* status_string = CodeUtility::toString(static_cast<Code>(numeric_status));
    uint32_t status_string_len = strlen(status_string);
    reason_phrase = {status_string, status_string_len};
  }

  connection_.buffer().addFragments(
      {response_prefix, absl::StrCat(numeric_status), SPACE, reason_phrase, CRLF});

  if (numeric_status >= 300) {
    // Don't do special CONNECT logic if the CONNECT was rejected.
    is_response_to_connect_request_ = false;
  }

  encodeHeadersBase(headers, absl::make_optional<uint64_t>(numeric_status), end_stream, false);
}
void ResponseEncoderImpl::encodeHeaders(const ResponseHeaderMap& headers, bool end_stream) {
  started_response_ = true;

   
  ASSERT(headers.Status() != nullptr);
  uint64_t numeric_status = Utility::getResponseStatus(headers);

  absl::string_view response_prefix;
  if (connection_.protocol() == Protocol::Http10 && connection_.supportsHttp10()) {
    response_prefix = HTTP_10_RESPONSE_PREFIX;
  } else {
    response_prefix = RESPONSE_PREFIX;
  }

  StatefulHeaderKeyFormatterOptConstRef formatter(headers.formatter());

  absl::string_view reason_phrase;
  if (formatter.has_value() && !formatter->getReasonPhrase().empty()) {
    reason_phrase = formatter->getReasonPhrase();
  } else {
    const char* status_string = CodeUtility::toString(static_cast<Code>(numeric_status));
    uint32_t status_string_len = strlen(status_string);
    reason_phrase = {status_string, status_string_len};
  }

  connection_.buffer().addFragments(
      {response_prefix, absl::StrCat(numeric_status), SPACE, reason_phrase, CRLF});

  if (numeric_status >= 300) {
     
    is_response_to_connect_request_ = false;
  }

  encodeHeadersBase(headers, absl::make_optional<uint64_t>(numeric_status), end_stream, false);
}