http-proxy 0.0.1 → 0.0.3
raw patch · 2 files changed
+13/−9 lines, 2 filesdep −blaze-builder-enumeratordep −unix-compat
Dependencies removed: blaze-builder-enumerator, unix-compat
Files
- Network/HTTP/Proxy.hs +9/−4
- http-proxy.cabal +4/−5
Network/HTTP/Proxy.hs view
@@ -17,7 +17,7 @@ --------------------------------------------------------- -- | This module contains a simple HTTP and HTTPS proxy. In the most basic--- setup, the caller specifies a port and runds it as follows:+-- setup, the caller specifies a port and runs it as follows: -- -- > -- Run a HTTPS and HTTPS proxy on port 3128. -- > import Network.HTTP.Proxy@@ -33,6 +33,7 @@ , Settings (..) , defaultSettings+ , Request (..) ) where @@ -152,6 +153,7 @@ runSettingsSocket :: Settings -> Socket -> IO () runSettingsSocket set sock = do let onE = proxyOnException set+ reqRM = proxyRequestModifier set port = proxyPort set tm <- T.initialize $ proxyTimeout set * 1000000 mgr <- HE.newManager@@ -159,7 +161,7 @@ (conn, sa) <- accept sock _ <- forkIO $ do th <- T.registerKillThread tm- serveConnection th tm onE port conn sa mgr+ serveConnection th tm onE reqRM port conn sa mgr T.cancel th return () @@ -196,10 +198,11 @@ serveConnection :: T.Handle -> T.Manager -> (SomeException -> IO ())+ -> (Request -> IO Request) -> Port -> Socket -> SockAddr -> HE.Manager -> IO ()-serveConnection th tm onException port conn remoteHost' mgr = do+serveConnection th tm onException requestMod port conn remoteHost' mgr = do mExtraSocket <- E.run_ (fromClient $$ serveConnection') `finally` sCloseX conn case mExtraSocket of@@ -217,7 +220,7 @@ --liftIO $ print $ requestHeaders req case req of _ | requestMethod req `elem` [ "GET", "POST" ] ->- proxyPlain req+ liftIO (requestMod req) >>= proxyPlain _ | requestMethod req == "CONNECT" -> case B.split ':' (rawPathInfo req) of [h, p] -> proxyConnect th tm onException conn h (readDecimal $ B.unpack p) req@@ -551,6 +554,7 @@ , proxyHost :: String -- ^ Host to bind to, or * for all. Default value: * , proxyOnException :: SomeException -> IO () -- ^ 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. , proxyTimeout :: Int -- ^ Timeout value in seconds. Default value: 30+ , proxyRequestModifier :: Request -> IO Request -- ^ A function that allows the the request to be modified before being run. Default: 'return . id'. } -- | The default settings for the Proxy server. See the individual settings for@@ -566,6 +570,7 @@ when (go' $ fromException e) $ hPutStrLn stderr $ show e , proxyTimeout = 30+ , proxyRequestModifier = return . id } where go :: InvalidRequest -> IO ()
http-proxy.cabal view
@@ -1,5 +1,5 @@ Name: http-proxy-Version: 0.0.1+Version: 0.0.3 License: BSD3 License-file: LICENSE Author: Michael Snoyman, Stephen Blackheath, Erik de Castro Lopo@@ -20,8 +20,9 @@ simultaneous connections and is independent of the size of the files being uploaded or downloaded. .- Eventually, features like logging, request re-writing, disk caching etc will- be made available via caller provided functions in the Settings data type.+ The Settings data type provided by the library allows the caller to supply+ a functions for exception reporting and request re-writing. Eventually, this+ capability will be expanded to allow options logging, disk caching etc. flag network-bytestring Default: False@@ -32,12 +33,10 @@ , wai >= 0.4 && < 0.5 , enumerator >= 0.4.8 && < 0.5 , http-enumerator >= 0.7 && < 0.8- , blaze-builder-enumerator >= 0.2 && < 0.3 , transformers >= 0.2.2 && < 0.3 , blaze-builder >= 0.2.1.4 && < 0.4 , http-types >= 0.6 && < 0.7 , case-insensitive >= 0.2- , unix-compat >= 0.2 if flag(network-bytestring) build-depends: network >= 2.2.1.5 && < 2.2.3 , network-bytestring >= 0.1.3 && < 0.1.4