<commit_before>/**
 * This file is part of the "FnordMetric" project
 *   Copyright (c) 2014 <NAME>, Google Inc.
 *
 * FnordMetric is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include "fnord/base/logging.h"
#include "fnord-rpc/RPCClient.h"

namespace fnord {

HTTPRPCClient::HTTPRPCClient(
    TaskScheduler* sched) :
    http_pool_(sched) {}

void HTTPRPCClient::call(const URI& uri, RefPtr<AnyRPC> rpc) {
  http::HTTPRequest http_req(http::HTTPRequest::M_POST, uri.path());

  http_req.addBody(rpc->encoded());
  http_req.setHeader("Host", uri.hostAndPort());

  auto http_future = http_pool_.executeRequest(http_req);

#ifndef FNORD_NOTRACE
  fnord::logTrace(
      "fnord.http.rpcclient",
      "executing RPC via HTTP request id=$2 method=$1 uri=$0",
      uri.toString(),
      rpc->method(),
      (void*) rpc.get());
#endif

  http_future.onSuccess([uri, rpc] (const http::HTTPResponse& resp) {
    if (resp.statusCode() < 200 || resp.statusCode() >= 300) {
      auto errmsg = StringUtil::format(<commit_msg>remotefeedreader stub<commit_after>/**
 * This file is part of the "FnordMetric" project
 *   Copyright (c) 2014 <NAME>, Google Inc.
 *
 * FnordMetric is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include "fnord/base/logging.h"
#include "fnord-rpc/RPCClient.h"

namespace fnord {

HTTPRPCClient::HTTPRPCClient(
    TaskScheduler* sched) :
    http_pool_(sched) {}

void HTTPRPCClient::call(const URI& uri, RefPtr<AnyRPC> rpc) {
  http::HTTPRequest http_req(http::HTTPRequest::M_POST, uri.path());

  http_req.addBody(rpc->encoded());
  http_req.setHeader("Host", uri.hostAndPort());

  auto http_future = http_pool_.executeRequest(http_req);

#ifndef FNORD_NOTRACE
  fnord::logTrace(
      "fnord.http.rpcclient",
      "executing RPC via HTTP request\n    id=$2\n    method=$1\n    uri=$0",
      uri.toString(),
      rpc->method(),
      (void*) rpc.get());
#endif

  http_future.onSuccess([uri, rpc] (const http::HTTPResponse& resp) {
    if (resp.statusCode() < 200 || resp.statusCode() >= 300) {
      auto errmsg = StringUtil::format(
{'fraction_non_alphanumeric': 0.13907815631262524, 'fraction_numerical': 0.012024048096192385, 'mean_word_length': 4.052631578947368, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2093787', 'n_tokens_mistral': 853, 'n_tokens_neox': 819, 'n_words': 222}