void ServiceControlHandlerImpl::callCheck()

in src/envoy/http/service_control/handler_impl.cc [196:252]


void ServiceControlHandlerImpl::callCheck(
    Envoy::Http::RequestHeaderMap& headers, Envoy::Tracing::Span& parent_span,
    CheckDoneCallback& callback) {
  // Don't have per-route config so pass through the request, regarded as the
  // unknown method.
  if (!isConfigured()) {
    callback.onCheckDone(OkStatus(), "");
    return;
  }
  check_callback_ = &callback;

  if (!isCheckRequired()) {
    callQuota();
    return;
  }

  if (!hasApiKey()) {
    filter_stats_.filter_.denied_consumer_error_.inc();
    check_status_ =
        Status(StatusCode::kUnauthenticated,
               "Method doesn't allow unregistered callers (callers without "
               "established identity). Please use API Key or other form of "
               "API consumer identity to call this API.");
    callback.onCheckDone(
        check_status_,
        utils::generateRcDetails(utils::kRcDetailFilterServiceControl,
                                 utils::kRcDetailErrorTypeBadRequest,
                                 utils::kRcDetailErrorMissingApiKey));
    return;
  }

  // Make a check call
  ::espv2::api_proxy::service_control::CheckRequestInfo info;
  fillOperationInfo(info);

  info.referer = std::string(
      utils::readHeaderEntry(headers.getInline(referer_handle.handle())));
  info.ios_bundle_id =
      std::string(utils::extractHeader(headers, kIosBundleIdHeader));
  info.android_package_name =
      std::string(utils::extractHeader(headers, kAndroidPackageHeader));
  info.android_cert_fingerprint =
      std::string(utils::extractHeader(headers, kAndroidCertHeader));

  on_check_done_called_ = false;
  cancel_fn_ = require_ctx_->service_ctx().call().callCheck(
      info, parent_span,
      [this, &headers](const Status& status,
                       const CheckResponseInfo& response_info) {
        cancel_fn_ = nullptr;
        on_check_done_called_ = true;
        onCheckResponse(headers, status, response_info);
      });
  if (on_check_done_called_) {
    cancel_fn_ = nullptr;
  }
}