From 03da3b021ac47b13975771a30ebe643cbc11bb27 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 3 Jan 2012 20:41:48 +0200 Subject: [PATCH] tests pass, except clean path --- yesod-core/Yesod/Dispatch.hs | 6 ++++-- yesod-core/Yesod/Handler.hs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/yesod-core/Yesod/Dispatch.hs b/yesod-core/Yesod/Dispatch.hs index 009b4abd..8951b192 100644 --- a/yesod-core/Yesod/Dispatch.hs +++ b/yesod-core/Yesod/Dispatch.hs @@ -43,6 +43,8 @@ import Data.ByteString.Lazy.Char8 () import Web.ClientSession import Data.Char (isUpper) import Data.Text (Text) +import Data.Text.Encoding (decodeUtf8With) +import Data.Text.Encoding.Error (lenientDecode) import Data.Monoid (mappend) import qualified Data.ByteString as S import qualified Blaze.ByteString.Builder @@ -170,8 +172,8 @@ toWaiApp' y key' env = yesodDispatch y y id app404 handler405 method (W.pathInfo env) key' env where app404 = yesodRunner notFound y y Nothing id - handler405 = error "handler405" - method = error "method" + handler405 route = yesodRunner badMethod y y (Just route) id + method = decodeUtf8With lenientDecode $ W.requestMethod env sendRedirect :: Yesod master => master -> [Text] -> W.Application sendRedirect y segments' env = diff --git a/yesod-core/Yesod/Handler.hs b/yesod-core/Yesod/Handler.hs index 3b8813e2..0b995485 100644 --- a/yesod-core/Yesod/Handler.hs +++ b/yesod-core/Yesod/Handler.hs @@ -600,7 +600,7 @@ notFound :: GHandler sub master a notFound = hcError NotFound -- | Return a 405 method not supported page. -badMethod :: GHandler s m a +badMethod :: GHandler sub master a badMethod = do w <- waiRequest hcError $ BadMethod $ W.requestMethod w