2026-01-02 13:41:09 +00:00
|
|
|
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
2022-08-26 13:09:22 +00:00
|
|
|
|
|
|
|
|
class UserAgentTestController < ApplicationController
|
|
|
|
|
skip_before_action :verify_csrf_token
|
|
|
|
|
|
|
|
|
|
# GET test/get
|
|
|
|
|
def get
|
|
|
|
|
process_request('get', 200)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET test/get_accepted
|
|
|
|
|
def accepted
|
|
|
|
|
process_request('get', 202)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# POST test/post
|
|
|
|
|
def post
|
|
|
|
|
process_request('post', 201)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# PUT test/put
|
|
|
|
|
def put
|
|
|
|
|
process_request('put', 200)
|
|
|
|
|
end
|
|
|
|
|
|
2025-01-09 14:47:18 +00:00
|
|
|
# PUT test/patch
|
|
|
|
|
def patch
|
|
|
|
|
process_request('patch', 200)
|
|
|
|
|
end
|
|
|
|
|
|
2022-08-26 13:09:22 +00:00
|
|
|
# DELETE test/delete
|
|
|
|
|
def delete
|
|
|
|
|
process_request('delete', 200)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET test/redirect
|
|
|
|
|
def redirect
|
2024-02-19 12:38:32 +00:00
|
|
|
redirect_to "#{request.protocol}#{request.host_with_port}/test/get/1?submitted=abc", allow_other_host: true
|
2022-08-26 13:09:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def process_request(type, status)
|
|
|
|
|
sleep_time = params[:sec].to_i > 1 ? params[:sec].to_i : 0.1
|
|
|
|
|
sleep sleep_time
|
|
|
|
|
|
|
|
|
|
render json: {
|
|
|
|
|
remote_ip: request.remote_ip,
|
2023-10-10 08:00:03 +00:00
|
|
|
content_type_requested: request.media_type,
|
2022-08-26 13:09:22 +00:00
|
|
|
method: type,
|
2026-04-21 15:50:00 +00:00
|
|
|
body: request.raw_post,
|
2022-08-26 13:09:22 +00:00
|
|
|
submitted: params[:submitted]
|
|
|
|
|
},
|
|
|
|
|
status: status
|
|
|
|
|
end
|
|
|
|
|
end
|