]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Resource/Internal.hs
Fix a long-standing bug in generating Allowed header values.
[Lucu.git] / Network / HTTP / Lucu / Resource / Internal.hs
index 9feca7edf6e3b6401fc7e4306705a420553fe016..7398f93e045cff87dd51b1241e23b0da70bcd3ca 100644 (file)
@@ -47,11 +47,11 @@ import Data.ByteString (ByteString)
 import qualified Data.ByteString as BS
 import Data.Collections
 import Data.Convertible.Base
+import Data.Convertible.Instances.Text ()
 import Data.List (intersperse, nub)
 import Data.Maybe
 import Data.Monoid
 import Data.Monoid.Unicode
-import qualified Data.Text as T
 import Network.HTTP.Lucu.Abortion
 import Network.HTTP.Lucu.Abortion.Internal
 import Network.HTTP.Lucu.Config
@@ -61,6 +61,7 @@ import Network.HTTP.Lucu.Interaction
 import Network.HTTP.Lucu.Postprocess
 import Network.HTTP.Lucu.Request
 import Network.HTTP.Lucu.Response
+import Network.HTTP.Lucu.Response.StatusCode
 import Network.HTTP.Lucu.Utils
 import Network.Socket
 #if defined(HAVE_SSL)
@@ -186,8 +187,8 @@ spawnRsrc (Resource {..}) ni@(NI {..})
                           $ map cs allowedMethods
 
       allowedMethods ∷ [Ascii]
-      allowedMethods = nub $ concat [ methods resGet    ["GET"]
-                                    , methods resHead   ["GET", "HEAD"]
+      allowedMethods = nub $ concat [ methods resGet    ["GET", "HEAD"]
+                                    , methods resHead   ["HEAD"]
                                     , methods resPost   ["POST"]
                                     , methods resPut    ["PUT"]
                                     , methods resDelete ["DELETE"]
@@ -202,7 +203,7 @@ spawnRsrc (Resource {..}) ni@(NI {..})
       toAbortion e
           = case fromException e of
               Just abortion → abortion
-              Nothing       → mkAbortion' InternalServerError $ T.pack $ show e
+              Nothing       → mkAbortion' InternalServerError $ cs $ show e
 
       processException ∷ SomeException → IO ()
       processException exc
@@ -302,7 +303,7 @@ getChunk' n
     | n < 0     = fail ("getChunk: n must not be negative: " ⧺ show n)
     | n ≡ 0     = return (∅)
     | otherwise = do req ← getRequest
-                     if reqMustHaveBody req then
+                     if reqHasBody req then
                          askForInput =≪ getInteraction
                      else
                          driftTo DecidingHeader *> return (∅)