HTTP 4000.0.6 → 4000.0.7
raw patch · 3 files changed
+48/−15 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.TCP: openSocketStream :: (HStream bufType) => String -> Socket -> IO (HandleStream bufType)
+ Network.TCP: socketConnection :: (BufferType ty) => String -> Socket -> IO (HandleStream ty)
Files
- CHANGES +12/−1
- HTTP.cabal +1/−1
- Network/TCP.hs +35/−13
CHANGES view
@@ -1,6 +1,17 @@+Version 4004.0.7: release 2009-05-22++ * Minor release.+ * Added + Network.TCP.openSocketStream :: (BufferType t)+ => String {-host-}+ -> Socket+ -> IO (HandleStream t)++ for interfacing to pre-existing @Socket@s. Contributed and+ suggested by <http://trac.haskell.org/http/ticket/7>.+ Version 4004.0.6: release 2009-04-21; changes from 4004.0.5 - * Patch release. * Network.Browser: use HTTP.HandleStream.sendHTTP_notify, not HTTP.sendHTTP_notify when issuing requests. The latter runs the risk of undoing request normalization. * Network.HTTP.Base.normalizeRequest: when normalizing proxy-bound requests,
HTTP.cabal view
@@ -1,5 +1,5 @@ Name: HTTP-Version: 4000.0.6+Version: 4000.0.7 Cabal-Version: >= 1.2 Build-type: Simple License: BSD3
Network/TCP.hs view
@@ -19,6 +19,7 @@ , isConnectedTo , openTCPConnection+ , socketConnection , isTCPConnectedTo , HandleStream@@ -126,7 +127,8 @@ -- your own @HStream@ instance is all it takes. -- class BufferType bufType => HStream bufType where- openStream :: String -> Int -> IO (HandleStream bufType)+ openStream :: String -> Int -> IO (HandleStream bufType)+ openSocketStream :: String -> Socket -> IO (HandleStream bufType) readLine :: HandleStream bufType -> IO (Result bufType) readBlock :: HandleStream bufType -> Int -> IO (Result bufType) writeBlock :: HandleStream bufType -> bufType -> IO (Result ())@@ -134,6 +136,7 @@ instance HStream Strict.ByteString where openStream = openTCPConnection+ openSocketStream = socketConnection readBlock c n = readBlockBS c n readLine c = readLineBS c writeBlock c str = writeBlockBS c str@@ -141,6 +144,7 @@ instance HStream Lazy.ByteString where openStream = \ a b -> openTCPConnection_ a b True+ openSocketStream = \ a b -> socketConnection_ a b True readBlock c n = readBlockBS c n readLine c = readLineBS c writeBlock c str = writeBlockBS c str@@ -154,6 +158,7 @@ instance HStream String where openStream = openTCPConnection+ openSocketStream = socketConnection readBlock ref n = readBlockBS ref n -- This function uses a buffer, at this time the buffer is just 1000 characters.@@ -187,18 +192,7 @@ hostA <- getHostAddr uri let a = SockAddrInet (toEnum port) hostA catchIO (connect s a) (\e -> sClose s >> ioError e)- h <- socketToHandle s ReadWriteMode- mb <- case stashInput of { True -> liftM Just $ buf_hGetContents bufferOps h; _ -> return Nothing }- let conn = MkConn - { connSock = s- , connHandle = h- , connBuffer = bufferOps- , connInput = mb- , connHost = uri- , connHooks = Nothing- }- v <- newMVar conn- return (HandleStream v)+ socketConnection_ uri s stashInput where getHostAddr h = do catchIO (inet_addr uri) -- handles ascii IP numbers@@ -211,6 +205,34 @@ getHostByName_safe h = catchIO (getHostByName h) (\ _ -> fail ("openTCPConnection: host lookup failure for " ++ show h))++-- | @socketConnection@, like @openConnection@ but using a pre-existing 'Socket'.+socketConnection :: BufferType ty+ => String+ -> Socket+ -> IO (HandleStream ty)+socketConnection hst sock = socketConnection_ hst sock False++-- Internal function used to control the on-demand streaming of input+-- for /lazy/ streams.+socketConnection_ :: BufferType ty+ => String+ -> Socket+ -> Bool+ -> IO (HandleStream ty)+socketConnection_ hst sock stashInput = do+ h <- socketToHandle sock ReadWriteMode+ mb <- case stashInput of { True -> liftM Just $ buf_hGetContents bufferOps h; _ -> return Nothing }+ let conn = MkConn + { connSock = sock+ , connHandle = h+ , connBuffer = bufferOps+ , connInput = mb+ , connHost = hst+ , connHooks = Nothing+ }+ v <- newMVar conn+ return (HandleStream v) closeConnection :: HandleStream a -> IO Bool -> IO () closeConnection ref readL = do