<commit_before>require 'pp'
require 'uri'
require 'net/http'
# require 'net/https'
# require 'rubygems'
# require 'crack'
require 'core_extensions'



class Request

  # url is a String
  # uri is a Uri
  attr_reader :url, :method, :http_verb
  attr_accessor :uri, :options
  
  def initialize(http_verb, url, options={})
    @http_verb = http_verb
    self.uri = url
    self.options = options
  end
  
  def uri=(url)
    @uri = URI.parse(url)
  end
  
  def perform
    http.request(request)
  end
  
  def request
    case @http_verb
      when :get, :GET, /\bget\b/i
        Net::HTTP::Get.new(@uri.path)
      when :post, :POST, /\bpost\b/i
        Net::HTTP::Post.new(@uri.path)
      when :head, :HEAD, /\bhead\b/i
        Net::HTTP::Head.new(@uri.path)
      else
        puts "HALP"
    end
  end
  
  private
    def http
      connection = Net::HTTP.new(@uri.host, @uri.port)
      connection
    end

end

q = Request.new(:get, "http://google.com")
puts q.perform<commit_msg>Handle HTTPS<commit_after>require 'pp'
require 'uri'
require 'net/http'
require 'net/https'
# require 'rubygems'

require 'core_extensions'



class Request

  # url is a String
  # uri is a Uri
  attr_reader :url, :method, :http_verb
  attr_accessor :uri, :options
  
  def initialize(http_verb, url, options={})
    @http_verb = http_verb
    self.uri = url
    self.options = options
  end
  
  def uri=(url)
    @uri = URI.parse(url)
  end
  
  def perform
    http.request(request, options.to_params)
  end
  
  def request
    case @http_verb
      when :get, :GET, /\bget\b/i
        Net::HTTP::Get.new(@uri.path)
      when :post, :POST, /\bpost\b/i
        Net::HTTP::Post.new(@uri.path, options.to_params)
      when :head, :HEAD, /\bhead\b/i
        Net::HTTP::Head.new(@uri.path, options.to_params)
      else
        puts "HALP"
    end
  end
  
  private
    def http
      connection = Net::HTTP.new(@uri.host, @uri.port)
      connection.use_ssl = @uri.is_a?(URI::HTTPS)
      connection.verify_mode = OpenSSL::SSL::VERIFY_NONE if connection.use_ssl
      connection
    end

end

q = Request.new(:get, "https://github.com/api/v2/xml/user/show/mwunsch")
puts q.perform
{'fraction_non_alphanumeric': 0.13443830570902393, 'fraction_numerical': 0.00046040515653775324, 'mean_word_length': 2.62771285475793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '7405071', 'n_tokens_mistral': 807, 'n_tokens_neox': 794, 'n_words': 185}