From e5d170aa66a9fdc2ba2258f42d054d7d998e5915 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 26 Aug 2023 10:58:10 +0200 Subject: Allow overriding default headers --- src/config/config.nim | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/config/config.nim') diff --git a/src/config/config.nim b/src/config/config.nim index e5dbad9c..afffdf23 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -90,6 +90,7 @@ type max_redirect*: int32 prepend_https*: bool proxy*: Opt[string] + default_headers*: Table[string, string] DisplayConfig = object color_mode*: Opt[ColorMode] @@ -141,14 +142,6 @@ type jsDestructor(Config) -const DefaultHeaders* = { - "User-Agent": "chawan", - "Accept": "text/html,text/*;q=0.5", - "Accept-Language": "en;q=1.0", - "Pragma": "no-cache", - "Cache-Control": "no-cache", -}.toTable().newHeaders()[] - func getForkServerConfig*(config: Config): ForkServerConfig = return ForkServerConfig( tmpdir: config.external.tmpdir, @@ -165,6 +158,9 @@ func getProxy*(config: Config): URL = raise newException(Defect, "Invalid proxy URL: " & s) return nil +func getDefaultHeaders*(config: Config): Headers = + return newHeaders(config.network.default_headers) + proc getBufferConfig*(config: Config, location: URL, cookiejar: CookieJar, headers: Headers, referer_from, scripting: bool, charsets: seq[Charset], images: bool, userstyle: string, proxy: URL, mimeTypes: MimeTypes): @@ -181,8 +177,6 @@ proc getBufferConfig*(config: Config, location: URL, cookiejar: CookieJar, proxy: proxy, mimeTypes: mimeTypes ) - new(result.headers) - result.headers[] = DefaultHeaders proc getSiteConfig*(config: Config, jsctx: JSContext): seq[SiteConfig] = for sc in config.siteconf: -- cgit 1.4.1-2-gfad0