<commit_before>
require 'rest-core/middleware'

require 'restclient'

require 'rest-core/patch/rest-client'

class RestCore::RestClient
  include RestCore::Middleware
  def call env
    process(env,
            ::RestClient::Request.execute(:method  => env[REQUEST_METHOD ],
                                          :url     => request_uri(env)    ,
                                          :payload => env[REQUEST_PAYLOAD],
                                          :headers => env[REQUEST_HEADERS]))

  rescue ::RestClient::Exception => e
    process(env, e.response)
  end

  def process env, response
    result = env.merge(RESPONSE_BODY    => response.body,
                       RESPONSE_STATUS  => response.code,
                       RESPONSE_HEADERS => response.raw_headers)
    result[ASYNC].call(result) if result[ASYNC]
    result<commit_msg>rest-client.rb: don't follow redirect. we follow redirect in a middleware<commit_after>
require 'rest-core/middleware'

require 'restclient'

require 'rest-core/patch/rest-client'

class RestCore::RestClient
  include RestCore::Middleware
  def call env
    process(env,
            ::RestClient::Request.execute(:method  => env[REQUEST_METHOD ],
                                          :url     => request_uri(env)    ,
                                          :payload => env[REQUEST_PAYLOAD],
                                          :headers => env[REQUEST_HEADERS],
                                          :max_redirects => 0))

  rescue ::RestClient::Exception => e
    process(env, e.response)
  end

  def process env, response
    result = env.merge(RESPONSE_BODY    => response.body,
                       RESPONSE_STATUS  => response.code,
                       RESPONSE_HEADERS => response.raw_headers)
    result[ASYNC].call(result) if result[ASYNC]
    result
{'fraction_non_alphanumeric': 0.09733550842849374, 'fraction_numerical': 0.000543773790103317, 'mean_word_length': 1.8134556574923548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4717166', 'n_tokens_mistral': 485, 'n_tokens_neox': 476, 'n_words': 98}