import Codec.Compression.GZip
import Control.Monad
import Data.Bits
-import Data.ByteString.Lazy (ByteString)
+import Data.ByteString.Base (LazyByteString)
import qualified Data.ByteString.Lazy as L
import Data.Char
import Data.Digest.SHA1
exports = [HsEVar (UnQual (HsIdent symName))]
imports = [ HsImportDecl undefined (Module "Codec.Binary.Base64")
False Nothing Nothing
- , HsImportDecl undefined (Module "Data.ByteString.Lazy")
- False Nothing (Just (False, [HsIVar (HsIdent "ByteString")]))
+ , HsImportDecl undefined (Module "Data.ByteString.Base")
+ False Nothing (Just (False, [HsIVar (HsIdent "LazyByteString")]))
, HsImportDecl undefined (Module "Data.ByteString.Lazy")
True (Just (Module "L")) Nothing
, HsImportDecl undefined (Module "Network.HTTP.Lucu")
expOutputGunzipped
expOutputGZipped)
expOutputGunzipped
- = (HsApp (HsVar (UnQual (HsIdent "outputBS")))
+ = (HsApp (HsVar (UnQual (HsIdent "outputLBS")))
(HsParen
(HsApp (HsVar (UnQual (HsIdent "decompress")))
(HsVar (UnQual (HsIdent "gzippedData"))))))
= HsQualifier (HsApp (HsVar (UnQual (HsIdent "setContentEncoding")))
(HsList [HsLit (HsString "gzip")]))
doOutputGZipped
- = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputBS")))
+ = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputLBS")))
(HsVar (UnQual (HsIdent "gzippedData"))))
in
HsApp (HsCon (UnQual (HsIdent "Just")))
= HsQualifier (HsApp (HsVar (UnQual (HsIdent "setContentType")))
(HsVar (UnQual (HsIdent "contentType"))))
doOutputRawData
- = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputBS")))
+ = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputLBS")))
(HsVar (UnQual (HsIdent "rawData"))))
in
HsApp (HsCon (UnQual (HsIdent "Just")))
declGZippedData
= [ HsTypeSig undefined [HsIdent "gzippedData"]
(HsQualType []
- (HsTyCon (UnQual (HsIdent "ByteString"))))
+ (HsTyCon (UnQual (HsIdent "LazyByteString"))))
, HsFunBind [HsMatch undefined (HsIdent "gzippedData")
[] (HsUnGuardedRhs defGZippedData) []]
]
declRawData
= [ HsTypeSig undefined [HsIdent "rawData"]
(HsQualType []
- (HsTyCon (UnQual (HsIdent "ByteString"))))
+ (HsTyCon (UnQual (HsIdent "LazyByteString"))))
, HsFunBind [HsMatch undefined (HsIdent "rawData")
[] (HsUnGuardedRhs defRawData) []]
]
getLastModified fpath = getModificationTime fpath
-getETag :: [CmdOpt] -> ByteString -> IO String
+getETag :: [CmdOpt] -> LazyByteString -> IO String
getETag opts input
= let eTagOpts = filter (\ x -> case x of
OptETag _ -> True
| n < 16 = (chr $ ord 'a' + n - 10)
-openInput :: FilePath -> IO ByteString
+openInput :: FilePath -> IO LazyByteString
openInput "-" = L.getContents
openInput fpath = L.readFile fpath
-}
module Foo.Bar.Baz (baz) where
import Codec.Binary.Base64
- import Data.ByteString.Lazy (ByteString)
+ import Data.ByteString.Base (LazyByteString)
import qualified Data.ByteString.Lazy as L
import Network.HTTP.Lucu
import System.Time
, resGet
= Just (do foundEntity entityTag lastModified
setContentType contentType
- outputBS rawData)
+ outputLBS rawData)
, resHead = Nothing
, resPost = Nothing
, resPut = Nothing
contentType :: MIMEType
contentType = read "image/png"
- rawData :: ByteString
+ rawData :: LazyByteString
rawData = L.pack (decode "IyEvdXNyL2Jpbi9lbnYgcnVuZ2hjCgppbXBvcnQgRGlzdHJ...")
------------------------------------------------------------------------------
mustGunzip <- liftM not (isEncodingAcceptable "gzip")
if mustGunzip then
- outputBS (decompress gzippedData)
+ outputLBS (decompress gzippedData)
else
do setContentEncoding ["gzip"]
- outputBS gzippedData
+ outputLBS gzippedData
, resHead = Nothing
, resPost = Nothing
, resPut = Nothing
}
-- rawData の代はりに gzippedData
- gzippedData :: ByteString
+ gzippedData :: LazyByteString
gzippedData = L.pack (decode "Otb/+DniOlRgAAAAYAAAAGAAAAB/6QOmToAEIGAAAAB...")
------------------------------------------------------------------------------
-}