Close http clients after using

The crystal http client maintains a keepalive connection to the other
server which stays alive for some time. This should be closed if the
client instance is not used again to avoid hogging resources
This commit is contained in:
Andrew Zhao
2020-12-23 00:52:23 -05:00
parent eeeecf9763
commit e0d25ff887
6 changed files with 30 additions and 11 deletions

View File

@@ -427,7 +427,7 @@ def generate_captcha(key, db)
end
def generate_text_captcha(key, db)
response = make_client(TEXTCAPTCHA_URL).get("/omarroth@protonmail.com.json").body
response = make_client(TEXTCAPTCHA_URL, &.get("/omarroth@protonmail.com.json").body)
response = JSON.parse(response)
tokens = response["a"].as_a.map do |answer|