<commit_before>module RestClient

  # A Response from RestClient, you can access the response body, the code or the headers.
  #
  module Response

    include AbstractResponse

    def body
      self
    end

    def self.create body, net_http_res, args, request
      result = body || ''
      result.extend Response

      result.response_set_vars(net_http_res, args, request)
      fix_encoding(result)

      result
    end

    private

    def self.fix_encoding(response)
      charset = RestClient::Utils.get_encoding_from_headers(response.headers)
      encoding = nil

      begin
        encoding = Encoding.find(charset) if charset
      rescue ArgumentError
        RestClient.log "No such encoding: #{charset.inspect}"
      end

      return unless encoding

      response.body.force_encoding(encoding)

      response
    end
  end
end<commit_msg>Make Response#body return a true String object.<commit_after>module RestClient

  # A Response from RestClient, you can access the response body, the code or the headers.
  #
  module Response

    include AbstractResponse

    def body
      @body ||= String.new(self)
    end

    def self.create body, net_http_res, args, request
      result = body || ''
      result.extend Response

      result.response_set_vars(net_http_res, args, request)
      fix_encoding(result)

      result
    end

    private

    def self.fix_encoding(response)
      charset = RestClient::Utils.get_encoding_from_headers(response.headers)
      encoding = nil

      begin
        encoding = Encoding.find(charset) if charset
      rescue ArgumentError
        RestClient.log "No such encoding: #{charset.inspect}"
      end

      return unless encoding

      response.force_encoding(encoding)

      response
    end
  end
end
{'fraction_non_alphanumeric': 0.06288601909039865, 'fraction_numerical': 0.0, 'mean_word_length': 2.636734693877551, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7289457', 'n_tokens_mistral': 504, 'n_tokens_neox': 473, 'n_words': 144}