<commit_before>require 'net/https'
require 'uri'

module Logglier
  module Client
    module HTTP

      def self.new(opts={})
        if opts[:threaded]
          Logglier::Client::HTTP::Threaded.new(opts)
        else
          Logglier::Client::HTTP::Sync.new(opts)
        end
      end

      module InstanceMethods

        # Sets up @http 
        #
        # @param [Hash] opts The options Hash
        # @option opts [String] :read_timeout The read timeout for the http connection
        # @option opts [String] :open_timeout The open timeout for the http connection
        def setup_http(opts={})
          @http = Net::HTTP.new(@input_uri.host, @input_uri.port)
          if @input_uri.scheme == 'https'
            @http.use_ssl = true
            @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
          end

          @http.read_timeout = opts[:read_timeout] || 2
          @http.open_timeout = opts[:open_timeout] || 2
        end

        # Delivers the message via HTTP, handling errors
        #
        # @param [String] message The message to deliver
        def deliver(message)
          begin
            @http.request_post(@input_uri.path, message)
          rescue TimeoutError, OpenSSL::SSL::SSLError, EOFError, Errno::ECONNRESET => e
            $stderr.puts "WARNING: #{e.class} posting message: #{message}"
          end
        end

      end

    end
  end
end

require File.join(File.dirname(__FILE__), 'http', 'sync')
require File.join(File.dirname(__FILE__), 'http', 'threaded')<commit_msg>Verify peer by default in HTTPS mode<commit_after>require 'net/https'
require 'uri'

module Logglier
  module Client
    module HTTP

      def self.new(opts={})
        if opts[:threaded]
          Logglier::Client::HTTP::Threaded.new(opts)
        else
          Logglier::Client::HTTP::Sync.new(opts)
        end
      end

      module InstanceMethods

        # Sets up @http
        #
        # @param [Hash] opts The options Hash
        # @option opts [Fixnum] :read_timeout The read timeout for the http connection
        # @option opts [Fixnum] :open_timeout The open timeout for the http connection
        # @option opts [Fixnum] :verify_mode OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER (default)
        # @option opts [String] :ca_file Path of a CA certification file in PEM format
        def setup_http(opts={})
          @http = Net::HTTP.new(@input_uri.host, @input_uri.port)
          if @input_uri.scheme == 'https'
            @http.use_ssl = true
            @http.verify_mode = opts[:verify_mode] || OpenSSL::SSL::VERIFY_PEER
            @http.ca_file = opts[:ca_file] if opts[:ca_file]
          end

          @http.read_timeout = opts[:read_timeout] || 2
          @http.open_timeout = opts[:open_timeout] || 2
        end

        # Delivers the message via HTTP, handling errors
        #
        # @param [String] message The message to deliver
        def deliver(message)
          begin
            @http.request_post(@input_uri.path, message)
          rescue TimeoutError, OpenSSL::SSL::SSLError, EOFError, Errno::ECONNRESET => e
            $stderr.puts "WARNING: #{e.class} posting message: #{message}"
          end
        end

      end

    end
  end
end

require File.join(File.dirname(__FILE__), 'http', 'sync')
require File.join(File.dirname(__FILE__), 'http', 'threaded')
{'fraction_non_alphanumeric': 0.10859188544152745, 'fraction_numerical': 0.0011933174224343676, 'mean_word_length': 2.3563563563563563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6482591', 'n_tokens_mistral': 995, 'n_tokens_neox': 980, 'n_words': 265}