From c8c606f96e8677f1f4ad682e18aae67121f25e9d Mon Sep 17 00:00:00 2001 From: drpepper66 Date: Fri, 17 Nov 2023 23:09:45 +0100 Subject: [PATCH] use stdlib http client --- src/auth.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/auth.nim b/src/auth.nim index 15db751..4de950b 100644 --- a/src/auth.nim +++ b/src/auth.nim @@ -1,7 +1,7 @@ #SPDX-License-Identifier: AGPL-3.0-only import std/[httpclient, asyncdispatch, times, json, random, sequtils, strutils, tables, packedsets, os, uri] import nimcrypto -import types, http_pool +import types import experimental/parser/guestaccount # max requests at a time per account to avoid race conditions @@ -216,13 +216,12 @@ proc updateAccountPool*(cfg: Config) {.async.} = while true: if accountPool.len == 0: - let pool = HttpPool() - log "fetching more accounts from service" + let client = newAsyncHttpClient() + try: - pool.use(newHttpHeaders()): - let resp = await c.get($(cfg.guestAccountsPoolUrl ? {"id": cfg.guestAccountsPoolId, "auth": cfg.guestAccountsPoolAuth})) + let resp = await client.get($(cfg.guestAccountsPoolUrl ? {"id": cfg.guestAccountsPoolId, "auth": cfg.guestAccountsPoolAuth})) let guestAccounts = await resp.body log "status code from service: ", resp.status @@ -233,6 +232,8 @@ proc updateAccountPool*(cfg: Config) {.async.} = except Exception as e: log "failed to fetch from accounts service: ", e.msg + finally: + client.close() accountPool.keepItIf(not it.hasExpired)