HTTP 3001.1.4 → 3001.1.5
raw patch · 6 files changed
+13/−131 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP: instance Typeable Request
+ Network.HTTP: instance Typeable Response
Files
- HTTP.cabal +2/−1
- Makefile +0/−35
- Network/HTTP.hs +11/−5
- README +0/−25
- test/Makefile +0/−16
- test/get.hs +0/−49
HTTP.cabal view
@@ -1,5 +1,5 @@ Name: HTTP-Version: 3001.1.4+Version: 3001.1.5 Cabal-Version: >= 1.2 Build-type: Simple License: BSD3@@ -37,6 +37,7 @@ Network.HTTP.MD5, Network.HTTP.MD5Aux GHC-options: -fwarn-missing-signatures+ Extensions: DeriveDataTypeable Build-depends: network, parsec if flag(old-base)
− Makefile
@@ -1,35 +0,0 @@-HADDOCK = haddock--TODAY = $(shell date +%Y%m%d)-DIST_NAME = http-$(TODAY)--HADDOCK_FILES = Network/HTTP.hs Network/Browser.hs --.PHONY: all configure build install dist haddock clean--default all: configure build--configure:- ./Setup.lhs configure--build:- ./Setup.lhs build--install:- ./Setup.lhs install--dist:- darcs dist --dist-name=$(DIST_NAME)--haddock: $(HADDOCK_FILES)- mkdir -p haddock- $(HADDOCK) -o haddock -h $^--clean:- -./Setup.lhs clean- -rm -rf haddock- -rm -rf dist- $(MAKE) -C test clean--setup: Setup.lhs- ghc --make -package Cabal -o setup Setup.lhs
Network/HTTP.hs view
@@ -153,7 +153,7 @@ import Text.Read.Lex (readDecP) import Text.ParserCombinators.ReadP ( ReadP, readP_to_S, char, (<++), look, munch )-+import Data.Typeable -- Turn on to enable HTTP traffic logging debug :: Bool@@ -256,7 +256,7 @@ , rqMethod :: RequestMethod , rqHeaders :: [Header] , rqBody :: String- }+ } deriving (Typeable) @@ -291,7 +291,7 @@ , rspReason :: String , rspHeaders :: [Header] , rspBody :: String- }+ } deriving (Typeable) -- This is an invalid representation of a received response, -- since we have made the assumption that all responses are HTTP/1.1@@ -530,7 +530,7 @@ do { rslt <- case tc of Nothing -> case cl of- Just x -> linearTransfer conn (read x :: Int)+ Just x -> linearTransferStrLen conn x Nothing -> hopefulTransfer conn "" Just x -> case map toLower (trim x) of@@ -586,7 +586,7 @@ rslt <- case tc of Nothing -> case cl of- Just x -> linearTransfer conn (read x :: Int)+ Just x -> linearTransferStrLen conn x Nothing -> return (Right ([], "")) -- hopefulTransfer "" Just x -> case map toLower (trim x) of@@ -606,6 +606,12 @@ -- The following functions were in the where clause of sendHTTP, they have -- been moved to global scope so other functions can access them. ++linearTransferStrLen :: Stream s => s -> String -> IO (Result ([Header],String))+linearTransferStrLen conn ns =+ case reads ns of+ [(n,"")] -> linearTransfer conn n+ _ -> return $ Left $ ErrorParse $ "Content-Length header contains not a number: " ++ show ns -- | Used when we know exactly how many bytes to expect. linearTransfer :: Stream s => s -> Int -> IO (Result ([Header],String))
− README
@@ -1,25 +0,0 @@-DESCRIPTION--This is the Haskell HTTP and Browser module package. It was originally-written by Warrick Gray and the original version is still available-from: http://homepages.paradise.net.nz/warrickg/haskell/http/--REQUIREMENTS--* A Haskell implementation such as GHC (http://www.haskell.org/ghc/)-or Hugs (http://www.haskell.org/hugs/) with support for Cabal.--INSTALLATION---* Configure:--$ runhaskell Setup.lhs configure--* Compile:--$ runhaskell Setup.lhs build--* Install (as root):--# runhaskell Setup.lhs install
− test/Makefile
@@ -1,16 +0,0 @@-GHC = ghc-GHCFLAGS = -O2 -package HTTP--TEST_PROGS = get--.SUFFIXES: .hs .hi .o--.PHONY: all clean--default all: $(TEST_PROGS)--%: %.hs- $(GHC) $(GHCFLAGS) --make -o $@ $<--clean:- -rm -f *.hi *.o $(TEST_PROGS)
− test/get.hs
@@ -1,49 +0,0 @@--- A simple test program which takes a url on the commandline--- and outputs the contents to stdout.---- ghc --make -package HTTP get.hs -o get--import Data.Char (intToDigit)-import Network.HTTP-import Network.URI-import System.Environment (getArgs)-import System.Exit (exitFailure)-import System.IO (hPutStrLn, stderr)--main = - do- args <- getArgs- case args of - [addr] -> case parseURI addr of- Nothing -> err "Could not parse URI"- Just uri -> do- cont <- get uri- putStr cont- _ -> err "Usage: get <url>"--err :: String -> IO a-err msg = do - hPutStrLn stderr msg- exitFailure--get :: URI -> IO String-get uri =- do- eresp <- simpleHTTP (request uri)- resp <- handleE (err . show) eresp- case rspCode resp of- (2,0,0) -> return (rspBody resp)- _ -> err (httpError resp)- where- showRspCode (a,b,c) = map intToDigit [a,b,c]- httpError resp = showRspCode (rspCode resp) ++ " " ++ rspReason resp--request :: URI -> Request-request uri = Request{ rqURI = uri,- rqMethod = GET,- rqHeaders = [],- rqBody = "" }--handleE :: Monad m => (ConnError -> m a) -> Either ConnError a -> m a-handleE h (Left e) = h e-handleE _ (Right v) = return v