mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
2492fe7715
This commit patches `Net::HTTP` to reduce the default timeouts of 60 seconds when we are processing a request. There are certain routes in Discourse which makes external requests and if the proper timeouts are not set, we risk having the Unicorn master process force restarting the Unicorn workers once the `30` seconds timeout is reached. This can potentially become a vector for DoS attacks and this commit is aimed at reducing the risk here.
18 lines
563 B
Ruby
18 lines
563 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
|
|
end
|
|
end
|