X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FResource%2FObject.hs;h=a18a268cb3504dc55badca12134cdf5883d02ed7;hb=602cb8599101da778f6cbb043451cfa458dff89c;hp=6f9bd1a05a1d38213a7ee9907628166c1ff21706;hpb=605a843e408a7ef475fbb5a26f408271ab315cc8;p=Rakka.git diff --git a/Rakka/Resource/Object.hs b/Rakka/Resource/Object.hs index 6f9bd1a..a18a268 100644 --- a/Rakka/Resource/Object.hs +++ b/Rakka/Resource/Object.hs @@ -3,6 +3,8 @@ module Rakka.Resource.Object ) where +import Data.ByteString.Char8 as C8 +import Data.Maybe import Network.HTTP.Lucu import Network.HTTP.Lucu.Utils import Rakka.Environment @@ -30,7 +32,7 @@ resObject env handleGet :: Environment -> PageName -> Resource () handleGet env name - = do pageM <- getPage (envStorage env) name + = do pageM <- getPage (envStorage env) name Nothing case pageM of Nothing -> foundNoEntity Nothing @@ -38,7 +40,7 @@ handleGet env name Just redir@(Redirection _ _ _ _) -> handleRedirect env redir - Just entity@(Entity _ _ _ _ _ _ _ _ _ _ _ _ _) + Just entity@(Entity _ _ _ _ _ _ _ _ _ _ _ _ _ _) -> handleGetEntity env entity @@ -63,8 +65,10 @@ handleGetEntity env page = do let lastMod = toClockTime $ pageLastMod page case pageRevision page of - Nothing -> foundTimeStamp lastMod - Just rev -> foundEntity (strongETag $ show rev) lastMod + 0 -> foundTimeStamp lastMod -- 0 はデフォルトページ + rev -> foundEntity (strongETag $ show rev) lastMod - setContentType (pageType page) - outputLBS (pageContent page) + setContentType (pageType page) + setHeader (C8.pack "Content-Disposition") + (C8.pack $ "attachment; filename=" ++ quoteStr (pageFileName' page)) + outputLBS (pageContent page)