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

require 'pathname'
require 'resourceful/header'

module Addressable
  class URI
    def absolute_path
      absolute_path = ""
      absolute_path << self.path.to_s
      absolute_path << "?#{self.query}" if self.query != nil
      absolute_path << "##{self.fragment}" if self.fragment != nil
      return absolute_path
    end
  end
end

module Resourceful

  class NetHttpAdapter
    # Make an HTTP request using the standard library net/http.
    #
    # Will use a proxy defined in the http_proxy environment variable, if set.
    #
    # @param [#read] body
    #   An IO-ish thing containing the body of the request
    #
    def make_request(method, uri, body = nil, header = nil)
      uri = uri.is_a?(Addressable::URI) ? uri : Addressable::URI.parse(uri)

      if [:put, :post].include? method
        body = body ? body.read : ""
        header[:content_length] = body.size 
      end

      req = net_http_request_class(method).new(uri.absolute_path)
      header.each_field { |k,v| req[k] = v } if header
      https = ("https" == uri.scheme)
      conn_class = proxy_details ? Net::HTTP.Proxy(*proxy_details) : Net::HTTP
      conn = conn_class.new(uri.host, uri.port || (https ? 443 : 80))
      conn.use_ssl = https
      begin 
        conn.start
        res = if body
                conn.request(req, body)
              else
                conn.request(req)
              end
      ensure
        conn.finish if conn.started?
      end

      [ Integer(res.code),
        Resourceful::Header.new(res.header.to_hash),
        res.body
      ]
    ensure
      <commit_msg>Forbid only the TRACE http method from having an entity body<commit_after>require 'net/http'
require 'net/https'
require 'addressable/uri'

require 'pathname'
require 'resourceful/header'

module Addressable
  class URI
    def absolute_path
      absolute_path = ""
      absolute_path << self.path.to_s
      absolute_path << "?#{self.query}" if self.query != nil
      absolute_path << "##{self.fragment}" if self.fragment != nil
      return absolute_path
    end
  end
end

module Resourceful

  class NetHttpAdapter
    # Make an HTTP request using the standard library net/http.
    #
    # Will use a proxy defined in the http_proxy environment variable, if set.
    #
    # @param [#read] body
    #   An IO-ish thing containing the body of the request
    #
    def make_request(method, uri, body = nil, header = nil)
      uri = uri.is_a?(Addressable::URI) ? uri : Addressable::URI.parse(uri)

      # http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.8
      # TRACE is the only method in shich a entity is forbidden
      unless :trace == method then
        body = body ? body.read : ""
        header[:content_length] = body.size 
      end

      req = net_http_request_class(method).new(uri.absolute_path)
      header.each_field { |k,v| req[k] = v } if header
      https = ("https" == uri.scheme)
      conn_class = proxy_details ? Net::HTTP.Proxy(*proxy_details) : Net::HTTP
      conn = conn_class.new(uri.host, uri.port || (https ? 443 : 80))
      conn.use_ssl = https
      begin 
        conn.start
        res = if body
                conn.request(req, body)
              else
                conn.request(req)
              end
      ensure
        conn.finish if conn.started?
      end

      [ Integer(res.code),
        Resourceful::Header.new(res.header.to_hash),
        res.body
      ]
    ensure
      
{'fraction_non_alphanumeric': 0.10505394662123793, 'fraction_numerical': 0.006246450880181715, 'mean_word_length': 2.3017806935332707, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '802789', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1063, 'n_words': 290}