about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-04 12:25:40 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-04 12:25:56 +0200
commitb96d8cc51a7f469eaa5804c24a8b45cc4d5b3756 (patch)
tree0d1deb5281e233d6627a4cfde91732c34adbbc05 /src/io
parente961b086d263022c3486a4742d1ab29331212c62 (diff)
downloadchawan-b96d8cc51a7f469eaa5804c24a8b45cc4d5b3756.tar.gz
Add proxy support
Diffstat (limited to 'src/io')
-rw-r--r--src/io/loader.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/io/loader.nim b/src/io/loader.nim
index 6583ce2c..46f694e6 100644
--- a/src/io/loader.nim
+++ b/src/io/loader.nim
@@ -84,6 +84,10 @@ type
     filter*: URLFilter
     cookiejar*: CookieJar
     referrerpolicy*: ReferrerPolicy
+    proxy*: URL
+    # When set to false, requests with a proxy URL are overridden by the
+    # loader proxy.
+    acceptProxy*: bool
 
   FetchPromise* = Promise[Result[Response, JSError]]
 
@@ -132,6 +136,8 @@ proc onLoad(ctx: LoaderContext, stream: Stream) =
       let r = getReferer(request.referer, request.url, ctx.config.referrerpolicy)
       if r != "":
         request.headers["Referer"] = r
+    if request.proxy == nil or not ctx.config.acceptProxy:
+      request.proxy = ctx.config.proxy
     ctx.loadResource(request, stream)
 
 proc acceptConnection(ctx: LoaderContext) =