]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Preprocess.hs
"driftTo Done" was trying to change the response header, which is impossible.
[Lucu.git] / Network / HTTP / Lucu / Preprocess.hs
index d951f6ae15bbba050036b5648d22f6bb8e3ca2bc..802338c46dddbf7df1fb9fbe06c25620f5aa6075 100644 (file)
@@ -1,5 +1,6 @@
+-- #hide
 module Network.HTTP.Lucu.Preprocess
-    ( preprocess -- Interaction -> STM ()
+    ( preprocess
     )
     where
 
@@ -70,28 +71,17 @@ preprocess itr
                 case reqMethod req of
                   GET  -> return ()
                   HEAD -> writeItr itr itrWillDiscardBody True
-                  POST -> ensureHavingBody itr
-                  PUT  -> ensureHavingBody itr
+                  POST -> writeItr itr itrRequestHasBody True
+                  PUT  -> writeItr itr itrRequestHasBody True
                   _    -> setStatus itr NotImplemented
                   
                 mapM_ (preprocessHeader itr) (reqHeaders req)
     where
-      ensureHavingBody itr
-          = let req = fromJust $ itrRequest itr
-            in
-              if getHeader "Content-Length"    req == Nothing &&
-                 getHeader "Transfer-Encoding" req == Nothing then
-
-                  setStatus itr LengthRequired
-              else
-                  writeItr itr itrRequestHasBody True
-
       setStatus itr status
-          = writeItr itr itrResponse $ Just (Response {
-                                               resVersion = HttpVersion 1 1
-                                             , resStatus  = status
-                                             , resHeaders = []
-                                             })
+          = updateItr itr itrResponse
+            $ \ res -> res {
+                         resStatus = status
+                       }
 
       preprocessHeader itr (name, value)
           = case map toLower name of