mirror of
https://github.com/discourse/discourse.git
synced 2025-06-20 06:31:40 +08:00

This change standardises the `User-Agent` header that Discourse will send when talking to other sites. `Discourse.user_agent` is now the authority on what the user agent value should be. For Onebox requests, this changes the user agent from their existing value to match the new value (unless overridden). For all other requests, `Net::HTTPHeader` is monkey-patched to add a default `User-Agent` header when one hasn't been provided.
24 lines
690 B
Ruby
24 lines
690 B
Ruby
# frozen_string_literal: true
|
|
|
|
# This controller's actions are only available in the test environment to help with more complex testing requirements
|
|
class TestRequestsController < ApplicationController
|
|
if Rails.env.test?
|
|
def test_net_http_timeouts
|
|
net_http = Net::HTTP.new("example.com")
|
|
|
|
render json: {
|
|
open_timeout: net_http.open_timeout,
|
|
read_timeout: net_http.read_timeout,
|
|
write_timeout: net_http.write_timeout,
|
|
max_retries: net_http.max_retries,
|
|
}
|
|
end
|
|
|
|
def test_net_http_headers
|
|
net_http_get = Net::HTTP::Get.new("example.com")
|
|
|
|
render json: net_http_get
|
|
end
|
|
end
|
|
end
|