def call(env)
      # calling env.dup here prevents bad things from happening
      request = Rack::Request.new(env.dup)

      # calling request.params is sufficient to trigger the error see
      # https://github.com/rack/rack/issues/337#issuecomment-46453404
      request.params
      @app.call(env)

    # Rescue from that specific ArgumentError
    rescue ArgumentError => e
      raise unless e.message =~ /invalid %-encoding/

      @logger.info "Bad request. Returning 400 due to #{e.message} from " + \
                   "request with env #{request.inspect}"
      error_response
    end
def call(env)
      # calling env.dup here prevents bad things from happening
      request = Rack::Request.new(env.dup)

      # calling request.params is sufficient to trigger the error see
      # https://github.com/rack/rack/issues/337#issuecomment-46453404
      request.params
      @app.call(env)

    # Rescue from that specific ArgumentError
    rescue ArgumentError => e
      raise unless e.message =~ /invalid %-encoding/

      @logger.info "Bad request. Returning 400 due to #{e.message} from " + \
                   "request with env #{request.inspect}"
      error_response
    end
Called by Rack when a request comes through