diff --git a/Network/HTTP.hs b/Network/HTTP.hs index d385ed4..319eff7 100644 --- a/Network/HTTP.hs +++ b/Network/HTTP.hs @@ -79,7 +79,7 @@ import Network.HTTP.Base import qualified Network.HTTP.HandleStream as S -- old implementation: import Network.HTTP.Stream import Network.TCP -import Network.Stream ( Result ) +import Network.Stream ( Result, ConnError(ErrorProxyConnection) ) import Network.URI ( parseURI ) import Data.Maybe ( fromMaybe ) diff --git a/Network/Stream.hs b/Network/Stream.hs index be535b0..f2ed490 100644 --- a/Network/Stream.hs +++ b/Network/Stream.hs @@ -37,6 +37,7 @@ data ConnError | ErrorClosed | ErrorParse String | ErrorMisc String + | ErrorProxyConnection String -- Added ErrorProxyConnection variant for proxy connection errors deriving(Show,Eq) -- in GHC 7.0 the Monad instance for Error no longer diff --git a/Network/StreamSocket.hs b/Network/StreamSocket.hs index 6755bed..c78178f 100644 --- a/Network/StreamSocket.hs +++ b/Network/StreamSocket.hs @@ -26,7 +26,7 @@ module Network.StreamSocket ) where import Network.Stream - ( Stream(..), ConnError(ErrorReset, ErrorMisc), Result + ( Stream(..), ConnError(ErrorReset, ErrorMisc, ErrorProxyConnection), Result ) import Network.Socket ( Socket, getSocketOption, shutdown @@ -49,6 +49,8 @@ handleSocketError sk e = case se of 0 -> ioError e 10054 -> return $ Left ErrorReset -- reset + -- Enhanced error handling for proxy connection issues + 10061 -> return $ Left $ ErrorProxyConnection "Proxy connection failed" _ -> return $ Left $ ErrorMisc $ show se myrecv :: Socket -> Int -> IO String @@ -94,4 +96,3 @@ writeBlockSocket sk str = (liftM Right $ fn str) `catchIO` (handleSocketError sk where fn [] = return () fn x = send sk (toUTF8BS x) >>= \i -> fn (drop i x) -