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

class Monitor
  class UrlMonitor
    attr_accessor :cookies, :response_time, :response, :data, :status, :error_count

    def initialize(url, cookies, params, &block)
      @exit_on_error = false
      @error_count = 0
      @cookies = cookies || {}
      cookieList = []
      @cookies.each {|key, value| cookieList << "#{key}=#{value}" }
      headers = {}
      headers['Cookie'] = cookieList.join('; ') unless cookieList.length == 0

      uri = URI.parse("#{$baseurl}#{url}")
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl  = true if uri.scheme == 'https'
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      req = Net::HTTP::Post.new(uri.path == '' ? '/' : uri.path, headers)
      req.form_data = params

      start = Time.now
      http.start {
        @response = http.request(req)
        @data = @response.body
        @status = @response.code.to_i
        pattern = Regexp.compile(/(.*?)=(.*?);.*?/)
        cookie = @response['set-cookie']
        unless cookie.nil?
          cookie.split(/, */).each {|token|
            # TODO: Add support for cookie deletions. This is broken right now
            # since deleted cookies are actually being 'added' instead.
            match = token.match(pattern)<commit_msg>Fixed an issue with exit_on_error default value<commit_after>require 'datastore'
require 'net/https'

class Monitor
  class UrlMonitor
    attr_accessor :cookies, :response_time, :response, :data, :status, :error_count

    def initialize(url, cookies, params, &block)
      @exit_on_error = true
      @error_count = 0
      @cookies = cookies || {}
      cookieList = []
      @cookies.each {|key, value| cookieList << "#{key}=#{value}" }
      headers = {}
      headers['Cookie'] = cookieList.join('; ') unless cookieList.length == 0

      uri = URI.parse("#{$baseurl}#{url}")
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl  = true if uri.scheme == 'https'
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      req = Net::HTTP::Post.new(uri.path == '' ? '/' : uri.path, headers)
      req.form_data = params

      start = Time.now
      http.start {
        @response = http.request(req)
        @data = @response.body
        @status = @response.code.to_i
        pattern = Regexp.compile(/(.*?)=(.*?);.*?/)
        cookie = @response['set-cookie']
        unless cookie.nil?
          cookie.split(/, */).each {|token|
            # TODO: Add support for cookie deletions. This is broken right now
            # since deleted cookies are actually being 'added' instead.
            match = token.match(pattern)
{'fraction_non_alphanumeric': 0.1511144692104269, 'fraction_numerical': 0.001511144692104269, 'mean_word_length': 2.5832205683355887, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1402828', 'n_tokens_mistral': 821, 'n_tokens_neox': 811, 'n_words': 195}