From ce026616e4972dd4d5c928620014fab353f67257 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Mon, 27 Nov 2023 23:06:14 +0000 Subject: [PATCH] Add support for http proxy --- CHANGELOG.md | 3 +++ src/Monocle/Client.hs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59239cf36..580f03bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## [master] ### Added + +- [crawler] Proxy can be configured with `http_proxy` and `https_proxy` environment. + ### Changed ### Removed ### Fixed diff --git a/src/Monocle/Client.hs b/src/Monocle/Client.hs index e2f50c4b7..f92fbae2e 100644 --- a/src/Monocle/Client.hs +++ b/src/Monocle/Client.hs @@ -26,6 +26,7 @@ import Network.HTTP.Client ( requestHeaders, responseBody, ) +import Network.HTTP.Client qualified import Network.HTTP.Client.OpenSSL qualified as OpenSSL import OpenSSL.Session (VerificationMode (VerifyNone)) import Proto3.Suite.JSONPB (FromJSONPB (..), ToJSONPB (..)) @@ -59,7 +60,11 @@ mkManager' verify = do Verify -> OpenSSL.defaultOpenSSLSettings tlsCiphers <- fromMaybe "DEFAULT" <$> lookupEnv "TLS_CIPHERS" ctx <- OpenSSL.defaultMakeContext (opensslSettings {OpenSSL.osslSettingsCiphers = tlsCiphers}) - newManager $ OpenSSL.opensslManagerSettings (pure ctx) + let settings = OpenSSL.opensslManagerSettings (pure ctx) + + -- setup proxy + let proxy = Network.HTTP.Client.proxyEnvironment Nothing + newManager (Network.HTTP.Client.managerSetProxy proxy settings) -- | Create the 'MonocleClient' withClient ::