-aboPage :: Config -> Abortion -> String
-aboPage conf abo
- = let [html] = unsafePerformIO
- $ runX ( mkDefaultPage conf (aboStatus abo) (txt $ aboMessage abo)
+-- aboMessage が Just なら單に mkDefaultPage に渡すだけで良いので樂だが、
+-- Nothing の場合は getDefaultPage を使ってデフォルトのメッセージを得な
+-- ければならない。しかもその時は resM から Response を捏造までする必要
+-- がある。
+abortPage :: Config -> Maybe Request -> Maybe Response -> Abortion -> String
+abortPage conf reqM resM abo
+ = let msg = case aboMessage abo of
+ Just msg -> msg
+ Nothing -> let res' = case resM of
+ Just res -> res { resStatus = aboStatus abo }
+ Nothing -> Response {
+ resVersion = HttpVersion 1 1
+ , resStatus = aboStatus abo
+ , resHeaders = []
+ }
+ res = foldl (.) id [setHeader name value
+ | (name, value) <- aboHeaders abo]
+ $ res'
+ in
+ getDefaultPage conf reqM res
+ [html] = unsafePerformIO
+ $ runX ( mkDefaultPage conf (aboStatus abo) (txt msg)