about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-21 19:04:37 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-21 19:36:12 +0100
commitabb09126edcce518614efc0e2c0d55d5e42f8094 (patch)
treedf9fc8832a0c4337b0561fafa850eff94ed71e56 /src/config
parente5b7c43c1e67f3f113e4ee266ff99d65a72598c6 (diff)
downloadchawan-abb09126edcce518614efc0e2c0d55d5e42f8094.tar.gz
config: add default-headers to siteconf
So long as we have to live with siteconf, let's at least make it useful.

Also, rewrite the header overriding logic because while it did work,
it only did so accidentally.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/config.nim16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 432f5875..a01187a7 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -47,6 +47,7 @@ type
     images*: Opt[bool]
     stylesheet*: Opt[string]
     proxy*: Opt[URL]
+    default_headers*: Opt[Table[string, string]]
 
   OmniRule* = object
     match*: Regex
@@ -87,7 +88,7 @@ type
     max_redirect* {.jsgetset.}: int32
     prepend_https* {.jsgetset.}: bool
     prepend_scheme* {.jsgetset.}: string
-    proxy* {.jsgetset.}: Opt[string]
+    proxy* {.jsgetset.}: URL
     default_headers* {.jsgetset.}: Table[string, string]
 
   DisplayConfig = object
@@ -249,19 +250,6 @@ proc bindLineKey(config: Config; key, action: string) {.jsfunc.} =
 proc hasprop(a: ptr ActionMap; s: string): bool {.jshasprop.} =
   return s in a[]
 
-func getProxy*(config: Config): URL =
-  if config.network.proxy.isSome:
-    let s = config.network.proxy.get
-    let x = parseURL(s)
-    if x.isSome:
-      return x.get
-    else:
-      raise newException(ValueError, "Invalid proxy URL: " & s)
-  return nil
-
-func getDefaultHeaders*(config: Config): Headers =
-  return newHeaders(config.network.default_headers)
-
 proc openFileExpand(dir, file: string): FileStream =
   if file.len == 0:
     return nil