mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Catch SSL shutdown errors when closing clients
This commit is contained in:
parent
b09798f2cf
commit
ee43d8cfb1
3 changed files with 11 additions and 3 deletions
|
|
@ -2,6 +2,8 @@ import strutils, sequtils, asyncdispatch, httpclient
|
|||
import ../utils, ../prefs
|
||||
export utils, prefs
|
||||
|
||||
from net import SslError
|
||||
|
||||
template cookiePrefs*(): untyped {.dirty.} =
|
||||
getPrefs(request.cookies.getOrDefault("preferences"), cfg)
|
||||
|
||||
|
|
@ -14,8 +16,12 @@ template refPath*(): untyped {.dirty.} =
|
|||
proc getNames*(name: string): seq[string] =
|
||||
name.strip(chars={'/'}).split(",").filterIt(it.len > 0)
|
||||
|
||||
proc safeClose*(client: AsyncHttpClient) =
|
||||
try: client.close()
|
||||
except SslError: discard
|
||||
|
||||
proc safeFetch*(url: string): Future[string] {.async.} =
|
||||
let client = newAsyncHttpClient()
|
||||
try: result = await client.getContent(url)
|
||||
except: discard
|
||||
client.close()
|
||||
client.safeClose()
|
||||
|
|
|
|||
Loading…
Reference in a new issue