import qualified Data.ByteString.Lazy as Lazy (ByteString)
import qualified Data.ByteString.Lazy as L hiding (ByteString)
import Data.Char
-import Data.Digest.SHA1
+import Data.Digest.SHA2
import Data.Int
import Data.Maybe
import Data.Time
False Nothing Nothing
, HsImportDecl undefined (Module "Data.ByteString.Lazy")
True (Just (Module "L")) Nothing
+ , HsImportDecl undefined (Module "Data.Maybe")
+ False Nothing Nothing
, HsImportDecl undefined (Module "Data.Time")
False Nothing Nothing
, HsImportDecl undefined (Module "Network.HTTP.Lucu")
defGZippedData
= HsApp (HsVar (Qual (Module "L") (HsIdent "pack")))
(HsParen
- (HsApp (HsVar (UnQual (HsIdent "decode")))
- (HsLit (HsString gzippedB64))))
+ (HsApp (HsVar (UnQual (HsIdent "fromJust")))
+ (HsParen
+ (HsApp (HsVar (UnQual (HsIdent "decode")))
+ (HsLit (HsString gzippedB64))))))
declRawData :: [HsDecl]
declRawData
defRawData
= HsApp (HsVar (Qual (Module "L") (HsIdent "pack")))
(HsParen
- (HsApp (HsVar (UnQual (HsIdent "decode")))
- (HsLit (HsString rawB64))))
+ (HsApp (HsVar (UnQual (HsIdent "fromJust")))
+ (HsParen
+ (HsApp (HsVar (UnQual (HsIdent "decode")))
+ (HsLit (HsString rawB64))))))
hPutStrLn output header
hPutStrLn output (prettyPrint hsModule)
getLastModified :: FilePath -> IO UTCTime
getLastModified "-" = getCurrentTime
getLastModified fpath = getFileStatus fpath
- >>= return . posixSecondsToUTCTime . toEnum . fromEnum . modificationTime
+ >>= return . posixSecondsToUTCTime . fromRational . toRational . modificationTime
getETag :: [CmdOpt] -> Lazy.ByteString -> IO String
_ -> error "too many --etag options."
where
mkETagFromInput :: String
- mkETagFromInput = "SHA-1:" ++ (toHex $ hash $ L.unpack input)
+ mkETagFromInput = "SHA-1:" ++ (toHex $ toOctets $ sha256 $ L.unpack input)
toHex :: [Word8] -> String
toHex [] = ""
module Foo.Bar.Baz (baz) where
import Codec.Binary.Base64
import qualified Data.ByteString.Lazy as L
+ import Data.Maybe
import Data.Time
import Network.HTTP.Lucu
contentType = read "image/png"
rawData :: L.ByteString
- rawData = L.pack (decode "IyEvdXNyL2Jpbi9lbnYgcnVuZ2hjCgppbXBvcnQgRGlzdHJ...")
+ rawData = L.pack (fromJust (decode "IyEvdXNyL2Jpbi9lbnYgcnVuZ2hjCgppbXBvcnQgRGlzdHJ..."))
------------------------------------------------------------------------------
壓縮される場合は次のやうに變はる:
-- rawData の代はりに gzippedData
gzippedData :: L.ByteString
- gzippedData = L.pack (decode "Otb/+DniOlRgAAAAYAAAAGAAAAB/6QOmToAEIGAAAAB...")
+ gzippedData = L.pack (fromJust (decode "Otb/+DniOlRgAAAAYAAAAGAAAAB/6QOmToAEIGAAAAB..."))
------------------------------------------------------------------------------
-}