<commit_before>module Rack
  class Headermap
    def initialize(app)
      @app = app
    end

    def call(env)
      path = env["PATH_INFO"]
      script_name = env['SCRIPT_NAME']
      env["PATH_INFO"] = env['HTTP_X_PATHINFO']
      env['SCRIPT_NAME'] = env['HTTP_X_SCRIPTNAME']
      @app.call(env)
    ensure
      env['PATH_INFO'] = path
      env['SCRIPT_NAME'] = script_name
    end
  end
end
<commit_msg>Don't set headers if there're not x-headers<commit_after>module Rack
  class Headermap
    def initialize(app)
      @app = app
    end

    def call(env)
      path = env['PATH_INFO']
      script_name = env['SCRIPT_NAME']
      if needed_x_headers_set?(env)
        env['PATH_INFO'] = env['HTTP_X_PATHINFO']
        env['SCRIPT_NAME'] = env['HTTP_X_SCRIPTNAME']
      end
      @app.call(env)
    ensure
      env['PATH_INFO'] = path
      env['SCRIPT_NAME'] = script_name
    end

    private

    def needed_x_headers_set?(env)
      env['HTTP_X_PATHINFO'] && env['HTTP_X_SCRIPTNAME']
    end
  end
end

{'fraction_non_alphanumeric': 0.11862745098039215, 'fraction_numerical': 0.0, 'mean_word_length': 2.7536764705882355, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2446895', 'n_tokens_mistral': 373, 'n_tokens_neox': 359, 'n_words': 71}