<commit_before>require 'xmlrpc/server'

class Feedback::PingbackController < ApplicationController
  def initialize
    @server = XMLRPC::BasicServer.new
    @server.add_handler('pingback.ping') do |source_uri, target_uri|
      self.pingback_ping(source_uri, target_uri)
    end
  end

  def index
    render :text => @server.process(request.body.read),
      :content_type => "text/xml; charset=utf-8", :layout => false
  end

  protected
  def pingback_ping(source_uri, target_uri)
    begin
      @pingback = FeedbackPingback.process_incoming_ping source_uri, target_uri
      return "Ping from #{source_uri} to #{target_uri} registered. Thanks for linking to us."
    rescue FeedbackPingback::Error => e
      logger.error "Ping from #{source_uri} to #{target_uri} failed with code #{e.faultCode} because #{e.faultString}"
      raise e
    rescue Exception => e
      logger.error "Ping from #{source_uri} to #{target_uri} failed because #{e}"
      raise FeedbackPingback::Error.error
    end
  end
end
<commit_msg>Added check for request.post? to prevent robot errors<commit_after>require 'xmlrpc/server'

class Feedback::PingbackController < ApplicationController
  def initialize
    @server = XMLRPC::BasicServer.new
    @server.add_handler('pingback.ping') do |source_uri, target_uri|
      self.pingback_ping(source_uri, target_uri)
    end
  end

  def index
    if request.post?
      render :text => @server.process(request.body.read),
      :content_type => "text/xml; charset=utf-8", :layout => false
    else
      render :nothing => true
    end
  end

  protected
  def pingback_ping(source_uri, target_uri)
    begin
      @pingback = FeedbackPingback.process_incoming_ping source_uri, target_uri
      return "Ping from #{source_uri} to #{target_uri} registered. Thanks for linking to us."
    rescue FeedbackPingback::Error => e
      logger.error "Ping from #{source_uri} to #{target_uri} failed with code #{e.faultCode} because #{e.faultString}"
      raise e
    rescue Exception => e
      logger.error "Ping from #{source_uri} to #{target_uri} failed because #{e}"
      raise FeedbackPingback::Error.error
    end
  end
end

{'fraction_non_alphanumeric': 0.10167130919220056, 'fraction_numerical': 0.0009285051067780873, 'mean_word_length': 3.7888888888888888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '7061063', 'n_tokens_mistral': 682, 'n_tokens_neox': 662, 'n_words': 180}