hxt-http 9.1.5 → 9.1.5.1
raw patch · 3 files changed
+78/−85 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hxt-http.cabal +7/−3
- src/Text/XML/HXT/Arrow/LibHTTPInput.hs +13/−13
- src/Text/XML/HXT/IO/GetHTTPNative.hs +58/−69
hxt-http.cabal view
@@ -1,5 +1,5 @@ Name: hxt-http-Version: 9.1.5+Version: 9.1.5.1 Synopsis: Interface to native Haskell HTTP package HTTP Description: Interface to native Haskell HTTP package HTTP. This package can be used as alternative for the hxt-curl package@@ -12,7 +12,7 @@ Maintainer: Uwe Schmidt <uwe@fh-wedel.de> Stability: Experimental Category: XML-Homepage: http://www.fh-wedel.de/~si/HXmlToolbox/index.html+Homepage: https://github.com/UweSchmidt/hxt Copyright: Copyright (c) 2011 Uwe Schmidt Build-type: Simple Cabal-version: >=1.6@@ -32,7 +32,7 @@ hs-source-dirs: src ghc-options: -Wall- ghc-prof-options: -auto-all -caf-all+ ghc-prof-options: -caf-all extensions: @@ -47,3 +47,7 @@ network >= 2.6 else build-depends: network < 2.6++Source-Repository head+ Type: git+ Location: git://github.com/UweSchmidt/hxt.git
src/Text/XML/HXT/Arrow/LibHTTPInput.hs view
@@ -21,24 +21,24 @@ ) where -import Control.Arrow -- arrow classes-import Control.Arrow.ArrowList-import Control.Arrow.ArrowTree-import Control.Arrow.ArrowIO+import Control.Arrow+import Control.Arrow.ArrowIO+import Control.Arrow.ArrowList+import Control.Arrow.ArrowTree -import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy as B -- import qualified Data.ByteString.Lazy.Char8 as C -import System.Console.GetOpt+import System.Console.GetOpt -import Text.XML.HXT.Arrow.DocumentInput ( addInputError )-import Text.XML.HXT.IO.GetHTTPNative ( getCont )+import Text.XML.HXT.Arrow.DocumentInput (addInputError)+import Text.XML.HXT.IO.GetHTTPNative (getCont) -import Text.XML.HXT.DOM.Interface+import Text.XML.HXT.DOM.Interface -import Text.XML.HXT.Arrow.XmlArrow-import Text.XML.HXT.Arrow.XmlState-import Text.XML.HXT.Arrow.XmlState.TypeDefs+import Text.XML.HXT.Arrow.XmlArrow+import Text.XML.HXT.Arrow.XmlState+import Text.XML.HXT.Arrow.XmlState.TypeDefs -- ---------------------------------------------------------- @@ -51,7 +51,7 @@ getSysVar (theInputOptions .&&&. theProxy .&&&. theStrictInput .&&&.- theRedirect+ theRedirect ) ) where
src/Text/XML/HXT/IO/GetHTTPNative.hs view
@@ -20,58 +20,47 @@ where -import Control.Arrow-import Control.Exception ( try )+import Control.Arrow+import Control.Exception (try) -import Text.XML.HXT.DOM.XmlKeywords-import Text.XML.HXT.DOM.TypeDefs ( Attributes )-import Text.XML.HXT.DOM.Util ( stringTrim )+import Text.XML.HXT.DOM.TypeDefs (Attributes)+import Text.XML.HXT.DOM.Util (stringTrim)+import Text.XML.HXT.DOM.XmlKeywords -import Text.XML.HXT.Arrow.XmlOptions ( a_if_modified_since- , a_if_unmodified_since- )+import Text.XML.HXT.Arrow.XmlOptions (a_if_modified_since,+ a_if_unmodified_since) -import Text.XML.HXT.Parser.ProtocolHandlerUtil ( parseContentType )+import Text.XML.HXT.Parser.ProtocolHandlerUtil (parseContentType) -import Text.ParserCombinators.Parsec ( parse )+import Text.ParserCombinators.Parsec (parse) -import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy as B -import Data.Char ( isDigit- )-import Data.Int ( Int64 )-import Data.List ( isPrefixOf- )-import Data.Maybe-import System.IO ( hPutStrLn- , stderr- )-import System.IO.Error ( ioeGetErrorString- )+import Data.Char (isDigit)+import Data.Int (Int64)+import Data.List (isPrefixOf)+import Data.Maybe+import System.IO (hPutStrLn, stderr)+import System.IO.Error (ioeGetErrorString) -import Network.Browser ( Proxy(..)- , BrowserAction- , browse- , defaultGETRequest_- , request- , setOutHandler- , setErrHandler- , setProxy- , setAllowRedirects- , setMaxRedirects- )-import Network.HTTP ( Header(..)- , HeaderName(..)- , Request(..)- , Response(..)- , httpVersion- , replaceHeader- )-import Network.Socket ( withSocketsDo- )-import Network.URI ( URI- , parseURIReference- )+import Network.Browser (BrowserAction,+ Proxy (..), browse,+ defaultGETRequest_,+ request,+ setAllowRedirects,+ setErrHandler,+ setMaxRedirects,+ setOutHandler,+ setProxy)+import Network.HTTP (Header (..),+ HeaderName (..),+ Request (..),+ Response (..),+ httpVersion,+ replaceHeader)+import Network.Socket (withSocketsDo)+import Network.URI (URI,+ parseURIReference) -- import qualified Debug.Trace as T -- ------------------------------------------------------------@@ -83,7 +72,7 @@ -- the http protocol handler, haskell implementation getCont :: Bool -> String -> String -> Bool -> Attributes ->- IO (Either ([(String, String)], String)+ IO (Either ([(String, String)], String) ([(String, String)], B.ByteString) ) getCont strictInput proxy uri redirect options@@ -108,19 +97,19 @@ processResponse response | ( (rc >= 200 && rc < 300) ||- rc == 304 -- not modified is o.k., this rc only occurs together with if-modified-since- ) + rc == 304 -- not modified is o.k., this rc only occurs together with if-modified-since+ ) && fileSizeOK = do if strictInput then B.length cs `seq` return res else return res- + | not fileSizeOK = return $ ers "999 max-filesize exceeded"- + | otherwise = return $ ers (show rc ++ " " ++ rr)@@ -150,21 +139,21 @@ where theRequest :: Request B.ByteString theRequest- = configHeaders $ defaultGETRequest_ uri' + = configHeaders $ defaultGETRequest_ uri' configHeaders :: Request B.ByteString -> Request B.ByteString- configHeaders- = foldr (>>>) id . map (uncurry replaceHeader) . concatMap (uncurry setHOption) $ options'+ configHeaders+ = foldr (>>>) id . map (uncurry replaceHeader) . concatMap (uncurry setHOption) $ options' - configHttp- = setOutHandler (trcFct)+ configHttp+ = setOutHandler (trcFct) : setErrHandler (trcFct) : ( if null proxy'- then return ()- else setProxy (Proxy proxy' Nothing)- )- : setAllowRedirects redirect'- : concatMap (uncurry setOption) options'+ then return ()+ else setProxy (Proxy proxy' Nothing)+ )+ : setAllowRedirects redirect'+ : concatMap (uncurry setOption) options' trcFct s | trc'@@ -213,7 +202,7 @@ addHttpAttr = [ (httpPrefix ++ (show name), value) ] -setOption :: String -> String -> [BrowserAction t ()]+setOption :: String -> String -> [BrowserAction t ()] setOption k0 v | k == "max-redirs" &&@@ -222,11 +211,11 @@ && null v = [setMaxRedirects Nothing] - | otherwise = []+ | otherwise = [] where k = dropCurlPrefix k0- -curlPrefix :: String++curlPrefix :: String curlPrefix = "curl--" dropCurlPrefix :: String -> String@@ -234,7 +223,7 @@ | curlPrefix `isPrefixOf` k = drop (length curlPrefix) k | otherwise = k -setHOption :: String -> String -> [(HeaderName, String)]+setHOption :: String -> String -> [(HeaderName, String)] setHOption k0 v | k `elem` [ "-A" , "user-agent"@@ -253,12 +242,12 @@ getCurlMaxFileSize :: Attributes -> Maybe Int64 getCurlMaxFileSize options- = (\ s -> if isIntArg s - then Just (read s) + = (\ s -> if isIntArg s+ then Just (read s) else Nothing ) . fromMaybe ""- . lookup (curlPrefix ++ "max-filesize") + . lookup (curlPrefix ++ "max-filesize") $ options- + -- ------------------------------------------------------------