<commit_before>module Twitpic
  class OAuth
    AUTH_PROVIDER_URL = 'https://api.twitter.com/1/account/verify_credentials.json'
    REALM = 'http://api.twitter.com/'
    
    def initialize(consumer_key, consumer_secret)
      @consumer_key = consumer_key
      @consumer_secret = consumer_secret
      @signature_method = 'HMAC-SHA1'
    end
    
    def authorize(access_token, access_secret)
      @access_token = access_token
      @access_secret = access_secret
    end
    
    def get(url, headers = {})
      raise NotImplemented.new('Sorry')
    end

    def head(url, headers = {})
      raise NotImplemented.new('Sorry')
    end

    def post(url, body = nil, headers = {})
      method = method.to_s
      uri = URI.parse(url)
      request = Net::HTTP::Post.new(uri.request_uri)
      request.body = body
      headers.each_pair {|k,v| request[k] = v}
      
      # add headers for OAuth Echo
      auth = make_auth_header(:GET, AUTH_PROVIDER_URL)
      request['X-Auth-Service-Provider'] = AUTH_PROVIDER_URL
      request['X-Verify-Credentials-Authorization'] = "#{auth}, realm=\"#{REALM}\""
      
      
      begin
        http = Net::HTTP.new(uri.host, uri.port).start
        response = http.request(request)
        return response.body
      rescue Errno::ECONNRESET
        raise HttpError.new("ERROR: Connection reset by peer")
        return
      rescue Errno::ETIMEDOUT
        raise HttpError.new("ERROR: Connection Timeout(Errno::ETIMEDOUT)")
        return
      rescue Timeout::Error
        raise HttpError.new("ERROR: Connection Timeout(Timeout::Error)")
        return
      end
    end

    def put(url, body = nil, headers = {})
      raise NotImplemented.new('Sorry')
    end

    def delete(url, headers = {})
      request(:DELETE, url, nil, headers)
    end
    
    private
      
      def make_auth_header(method, url, body = nil)
        method = method.to_s<commit_msg>first commit<commit_after>module Twitpic
  class OAuth
    AUTH_PROVIDER_URL = 'https://api.twitter.com/1/account/verify_credentials.json'
    REALM = 'http://api.twitter.com/'
    
    def initialize(consumer_key, consumer_secret)
      @consumer_key = consumer_key
      @consumer_secret = consumer_secret
      @signature_method = 'HMAC-SHA1'
    end
    
    def authorize(access_token, access_secret)
      @access_token = access_token
      @access_secret = access_secret
    end
    
    def get(url, headers = {})
      raise NotImplemented.new('Sorry')
    end

    def head(url, headers = {})
      raise NotImplemented.new('Sorry')
    end

    def post(url, body = nil, headers = {})
      method = method.to_s
      uri = URI.parse(url)
      request = Net::HTTP::Post.new(uri.request_uri)
      request.body = body
      headers.each_pair {|k,v| request[k] = v}
      
      # add headers for OAuth Echo
      auth = make_auth_header(:GET, AUTH_PROVIDER_URL)
      request['X-Auth-Service-Provider'] = AUTH_PROVIDER_URL
      request['X-Verify-Credentials-Authorization'] = "#{auth}, realm=\"#{REALM}\""
      
      
      begin
        http = Net::HTTP.new(uri.host, uri.port).start
        response = http.request(request)
        return response.body
      rescue Errno::ECONNRESET
        raise HttpError.new("ERROR: Connection reset by peer")
        return
      rescue Errno::ETIMEDOUT
        raise HttpError.new("ERROR: Connection Timeout(Errno::ETIMEDOUT)")
        return
      rescue Timeout::Error
        raise HttpError.new("ERROR: Connection Timeout(Timeout::Error)")
        return
      end
    end

    def put(url, body = nil, headers = {})
      raise NotImplemented.new('Sorry')
    end

    def delete(url, headers = {})
      raise NotImplemented.new('Sorry')
    end
    
    private
      
      def make_auth_header(method, url, body = nil)
        method = method.to_s
{'fraction_non_alphanumeric': 0.11163398692810457, 'fraction_numerical': 0.0010457516339869282, 'mean_word_length': 2.519779208831647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2807803', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1190, 'n_words': 248}