@@ -105,22 +105,36 @@ runProxySettingsSocket set sock = do
105105--
106106-- > defaultProxySettings { proxyPort = 3128 }
107107data Settings = Settings
108- { proxyPort :: Int -- ^ Port to listen on. Default value: 3100
109- , proxyHost :: HostPreference -- ^ Default value: HostIPv4
110- , proxyOnException :: SomeException -> Wai. Response -- ^ What to do with exceptions thrown by either the application or server. Default: ignore server-generated exceptions (see 'InvalidRequest') and print application-generated applications to stderr.
111- , proxyTimeout :: Int -- ^ Timeout value in seconds. Default value: 30
112- , proxyRequestModifier :: Request -> IO (Either Response Request ) -- ^ A function that allows the request to be modified before being run. Default: 'return . Right'.
113- , proxyLogger :: ByteString -> IO () -- ^ A function for logging proxy internal state. Default: 'return ()'.
114- , proxyUpstream :: Maybe UpstreamProxy -- ^ Optional upstream proxy.
108+ { proxyPort :: Int
109+ -- ^ Port to listen on. Default value: 3100
110+ , proxyHost :: HostPreference
111+ -- ^ Default value: HostIPv4
112+ , proxyOnException :: SomeException -> Wai. Response
113+ -- ^ What to do with exceptions thrown by either the application or server.
114+ -- Default: ignore server-generated exceptions (see 'InvalidRequest') and print
115+ -- application-generated applications to stderr.
116+ , proxyTimeout :: Int
117+ -- ^ Timeout value in seconds. Default value: 30
118+ , proxyRequestModifier :: Request -> IO (Either Response Request )
119+ -- ^ A function that allows the request to be modified before being run. Default: 'return . Right'.
120+ -- This only works for unencrypted HTTP requests (eg to upgrade the request to HTTPS) because
121+ -- HTTPS requests are encrypted.
122+ , proxyLogger :: ByteString -> IO ()
123+ -- ^ A function for logging proxy internal state. Default: 'return ()'.
124+ , proxyUpstream :: Maybe UpstreamProxy
125+ -- ^ Optional upstream proxy.
115126 }
116127
117128-- | A http-proxy can be configured to use and upstream proxy by providing the
118129-- proxy name, the port it listens to and an option username and password for
119130-- proxy authorisation.
120131data UpstreamProxy = UpstreamProxy
121- { upstreamHost :: ByteString -- ^ The upstream proxy's hostname.
122- , upstreamPort :: Int -- ^ The upstream proxy's port number.
123- , upstreamAuth :: Maybe (ByteString , ByteString ) -- ^ Optional username and password to use with upstream proxy.
132+ { upstreamHost :: ByteString
133+ -- ^ The upstream proxy's hostname.
134+ , upstreamPort :: Int
135+ -- ^ The upstream proxy's port number.
136+ , upstreamAuth :: Maybe (ByteString , ByteString )
137+ -- ^ Optional username and password to use with upstream proxy.
124138 }
125139
126140
@@ -147,9 +161,9 @@ defaultProxySettings = Settings
147161
148162defaultExceptionResponse :: SomeException -> Wai. Response
149163defaultExceptionResponse e =
150- Wai. responseLBS HT. internalServerError500
151- [ (HT. hContentType, " text/plain; charset=utf-8" ) ]
152- $ LBS. fromChunks [BS. pack $ show e]
164+ Wai. responseLBS HT. internalServerError500
165+ [ (HT. hContentType, " text/plain; charset=utf-8" ) ]
166+ $ LBS. fromChunks [BS. pack $ show e]
153167
154168-- -----------------------------------------------------------------------------
155169-- Application == Wai.Request -> (Wai.Response -> IO Wai.ResponseReceived) -> IO Wai.ResponseReceived
@@ -197,13 +211,7 @@ doUpstreamRequest settings mgr respond mwreq
197211 errorResponse = proxyOnException settings . toException
198212
199213
200- -- handleConnect :: Wai.Request -> ConduitT IO BS.ByteString -> ConduitT BS.ByteString IO () -> IO ()
201-
202- handleConnect :: Wai. Request
203- -> ConduitT () ByteString IO ()
204- -> ConduitT ByteString Void IO a
205- -> IO ()
206-
214+ handleConnect :: Wai. Request -> ConduitT () ByteString IO () -> ConduitT ByteString Void IO a -> IO ()
207215handleConnect wreq fromClient toClient = do
208216 let (host, port) =
209217 case BS. break (== ' :' ) $ Wai. rawPathInfo wreq of
0 commit comments