@@ -38,7 +38,6 @@ import Control.Applicative ((<$>))
3838import Control.Exception (Exception, throwIO, bracket, finally, handle, fromException, try, IOException, onException)
3939import Control.Monad (void)
4040import qualified Crypto.Random.AESCtr
41−import qualified Data.ByteString as B
4241import qualified Data.ByteString as S
4342import qualified Data.ByteString.Lazy as L
4443import Data.Default.Class (def)
@@ -257,14 +256,14 @@ mkConn :: TLS.TLSParams params => TLSSettings -> Socket -> params -> IO (Connect
257256mkConn tlsset s params = do
258257 firstBS <- safeRecv s 4096
259258 cachedRef <- I.newIORef firstBS
260− (if not (B.null firstBS) && B.head firstBS == 0x16 then
259+ (if not (S.null firstBS) && S.head firstBS == 0x16 then
261260 httpOverTls tlsset s cachedRef params
262261 else
263262 plainHTTP tlsset s cachedRef) `onException` sClose s
264263
265264----------------------------------------------------------------
266265
267−httpOverTls :: TLS.TLSParams params => TLSSettings -> Socket -> I.IORef B.ByteString -> params -> IO (Connection, Transport)
266+httpOverTls :: TLS.TLSParams params => TLSSettings -> Socket -> I.IORef S.ByteString -> params -> IO (Connection, Transport)
268267httpOverTls TLSSettings{..} s cachedRef params = do
269268#if MIN_VERSION_tls(1,3,0)
270269 ctx <- TLS.contextNew backend params
@@ -305,11 +304,11 @@ httpOverTls TLSSettings{..} s cachedRef params = do
305304 recv = handle onEOF go
306305 where
307306 onEOF e
308− | Just TLS.Error_EOF <- fromException e = return B.empty
309− | Just ioe <- fromException e, isEOFError ioe = return B.empty | otherwise = throwIO e
307+ | Just TLS.Error_EOF <- fromException e = return S.empty
308+ | Just ioe <- fromException e, isEOFError ioe = return S.empty | otherwise = throwIO e
310309 go = do
311310 x <- TLS.recvData ctx
312− if B.null x then
311+ if S.null x then
313312 go
314313 else
315314 return x
@@ -339,7 +338,7 @@ tryIO = try
339338
340339----------------------------------------------------------------
341340
342−plainHTTP :: TLSSettings -> Socket -> I.IORef B.ByteString -> IO (Connection, Transport)
341+plainHTTP :: TLSSettings -> Socket -> I.IORef S.ByteString -> IO (Connection, Transport)
343342plainHTTP TLSSettings{..} s cachedRef = case onInsecure of
344343 AllowInsecure -> do
345344 conn' <- socketConnection s
@@ -355,36 +354,36 @@ plainHTTP TLSSettings{..} s cachedRef = case onInsecure of
355354
356355----------------------------------------------------------------
357356
358−recvTLS :: I.IORef B.ByteString -> Socket -> Int -> IO B.ByteString
357+recvTLS :: I.IORef S.ByteString -> Socket -> Int -> IO S.ByteString
359358recvTLS cachedRef s size = do
360359 cached <- I.readIORef cachedRef
361360 loop cached
362361 where
363− loop bs | B.length bs >= size = do
364− let (x, y) = B.splitAt size bs
362+ loop bs | S.length bs >= size = do
363+ let (x, y) = S.splitAt size bs
365364 I.writeIORef cachedRef y
366365 return x
367366 loop bs1 = do
368367 bs2 <- safeRecv s 4096
369− if B.null bs2 then do
368+ if S.null bs2 then do
370369 -- FIXME does this deserve an exception being thrown?
371− I.writeIORef cachedRef B.empty
370+ I.writeIORef cachedRef S.empty
372371 return bs1
373372 else
374− loop $ B.append bs1 bs2
373+ loop $ S.append bs1 bs2
375374
376375----------------------------------------------------------------
377376
378377-- | Modify the given receive function to first check the given @IORef@ for a
379378-- chunk of data. If present, takes the chunk of data from the @IORef@ and
380379-- empties out the @IORef@. Otherwise, calls the supplied receive function.
381−recvPlain :: I.IORef B.ByteString -> IO B.ByteString -> IO B.ByteString
380+recvPlain :: I.IORef S.ByteString -> IO S.ByteString -> IO S.ByteString
382381recvPlain ref fallback = do
383382 bs <- I.readIORef ref
384− if B.null bs
383+ if S.null bs
385384 then fallback
386385 else do
387− I.writeIORef ref B.empty
386+ I.writeIORef ref S.empty
388387 return bs
389388
390389----------------------------------------------------------------