void onSuccess()

in src/envoy/http/service_control/http_call.cc [85:131]


  void onSuccess(const Envoy::Http::AsyncClient::Request&,
                 Envoy::Http::ResponseMessagePtr&& response) override {
    ENVOY_LOG(trace, "{}", __func__);

    std::string body;
    try {
      const uint64_t status_code =
          Envoy::Http::Utility::getResponseStatus(response->headers());

      request_span_->setTag(Envoy::Tracing::Tags::get().HttpStatusCode,
                            std::to_string(status_code));
      request_span_->finishSpan();

      if (response->body().length() > 0) {
        const auto len = response->body().length();
        body = std::string(static_cast<char*>(response->body().linearize(len)),
                           len);
      }
      if (status_code == Envoy::enumToInt(Envoy::Http::Code::OK)) {
        ENVOY_LOG(debug, "http call [uri = {}]: success with body {}", uri_,
                  body);
        on_done_(OkStatus(), body);
      } else {
        ENVOY_LOG(debug, "http call response status code: {}, body: {}",
                  status_code, body);

        if (attemptRetry(status_code)) {
          return;
        }

        std::string error_msg = absl::StrCat(
            "Calling Google Service Control API failed with: ", status_code);
        if (!body.empty()) {
          absl::StrAppend(&error_msg, " and body: ", body);
        }
        auto grpc_code = Envoy::Grpc::Utility::httpToGrpcStatus(status_code);
        on_done_(Status(static_cast<StatusCode>(grpc_code), error_msg), body);
      }
    } catch (const Envoy::EnvoyException& e) {
      ENVOY_LOG(debug, "http call invalid status");
      on_done_(Status(StatusCode::kInternal, "Failed to call service control"),
               body);
    }

    reset();
    deferredDelete();
  }