Configurable read timeout (#108)

This commit is contained in:
Alex Ling 2020-10-15 11:51:04 +00:00
parent 3bb0917374
commit 853f422964
3 changed files with 14 additions and 1 deletions

View File

@ -18,6 +18,7 @@ class Config
home: true
property plugin_path : String = File.expand_path "~/mango/plugins",
home: true
property download_timeout_seconds : Int32 = 30
property mangadex = Hash(String, String | Int32).new
@[YAML::Field(ignore: true)]

View File

@ -5,7 +5,7 @@ require "http_proxy"
module HTTP
class Client
private def self.exec(uri : URI, tls : TLSContext = nil)
Logger.debug "Using monkey-patched HTTP::Client"
Logger.debug "Setting proxy"
previous_def uri, tls do |client, path|
client.set_proxy get_proxy uri
yield client, path

View File

@ -81,3 +81,15 @@ macro get_sort_opt
sort_opt = SortOptions.new sort_method, is_ascending
end
end
module HTTP
class Client
private def self.exec(uri : URI, tls : TLSContext = nil)
Logger.debug "Setting read timeout"
previous_def uri, tls do |client, path|
client.read_timeout = Config.current.download_timeout_seconds.seconds
yield client, path
end
end
end
end