Fix timeout.
This commit is contained in:
parent
7bc9261ff9
commit
0e7aa6249b
|
@ -358,9 +358,21 @@ namespace :sync_asia_personal_plugins do
|
|||
AsiaSyncPlugin.sync_college_projects(query_result, user)
|
||||
end
|
||||
end
|
||||
def net_http_get_response(uri,headers={})
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
if uri.scheme == "https"
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
end
|
||||
http.read_timeout = (@read_timeout.nil? ? 60 : @read_timeout)
|
||||
res = http.get((uri.path.blank? ? "/" : uri.path)+(uri.query.blank? ? '' : "?#{uri.query}"))
|
||||
res.uri = uri
|
||||
res
|
||||
end
|
||||
def get_sync_data(user_id)
|
||||
uri = URI.parse("https://webap.asia.edu.tw/cfd2020/API/Research/Load")
|
||||
res = Net::HTTP.get_response(uri + "?#{{:id=> user_id}.to_query}")
|
||||
@read_timeout = 300
|
||||
res = net_http_get_response(uri + "?#{{:id=> user_id}.to_query}")
|
||||
return JSON.parse(res.body,{object_class: AsiaSyncPlugin::SafeHash})
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue