<commit_before>class ServiceConverter

  @@convert_timeout = Rails.configuration.timeout
  @@document_converter_url = Rails.configuration.urlConverter
  @@convert_params = '?url=%s&outputtype=%s&filetype=%s&title=%s&key=%s'

  class << self

    def get_converted_uri(document_uri, from_ext, to_ext, document_revision_id, is_async)

      from_ext = from_ext == nil ? File.extname(document_uri) : from_ext

      title = File.basename(URI.parse(document_uri).path)
      title = title == nil ? UUID.generate.to_s : title

      document_revision_id = document_revision_id.empty? ? document_uri : document_revision_id
      document_revision_id = generate_revision_id(document_revision_id)

      url_to_converter = @@document_converter_url +
          (@@convert_params % [URI::encode(document_uri), to_ext.delete('.'), from_ext.delete('.'), title, document_revision_id])

      if is_async
        url_to_converter += '&async=true'
      end

      data = nil
      begin

        uri = URI.parse(url_to_converter)
        http = Net::HTTP.new(uri.host, uri.port)

        if url_to_converter.start_with?('https')
          http.use_ssl = true
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end

        http.read_timeout = @@convert_timeout
        req = Net::HTTP::Get.new(uri.request_uri)
        req.add_field("Accept", "application/json")
        res = http.request(req)
        data = res.body
      rescue TimeoutError
        #try again
      rescue => ex
        raise ex.message
      end
<commit_msg>ruby: send POST instead of GET on convert request<commit_after>class ServiceConverter

  @@convert_timeout = Rails.configuration.timeout
  @@document_converter_url = Rails.configuration.urlConverter

  class << self

    def get_converted_uri(document_uri, from_ext, to_ext, document_revision_id, is_async)

      from_ext = from_ext == nil ? File.extname(document_uri) : from_ext

      title = File.basename(URI.parse(document_uri).path)
      title = title == nil ? UUID.generate.to_s : title

      document_revision_id = document_revision_id.empty? ? document_uri : document_revision_id
      document_revision_id = generate_revision_id(document_revision_id)

      payload = {
        :async => is_async ? true : false,
        :url => document_uri,
        :outputtype => to_ext.delete('.'),
        :filetype => from_ext.delete('.'),
        :title => title,
        :key => document_revision_id
      }

      data = nil
      begin

        uri = URI.parse(@@document_converter_url)
        http = Net::HTTP.new(uri.host, uri.port)

        if @@document_converter_url.start_with?('https')
          http.use_ssl = true
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end

        http.read_timeout = @@convert_timeout
        req = Net::HTTP::Post.new(uri.request_uri)
        req.add_field("Accept", "application/json")
        req.add_field("Content-Type", "application/json")
        req.body = payload.to_json
        res = http.request(req)
        data = res.body
      rescue TimeoutError
        #try again
      rescue => ex
        raise ex.message
      end

{'fraction_non_alphanumeric': 0.10854947166186359, 'fraction_numerical': 0.0, 'mean_word_length': 2.8952618453865338, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5395360', 'n_tokens_mistral': 1000, 'n_tokens_neox': 965, 'n_words': 174}