]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Preprocess.hs
Optimized as possible as I can.
[Lucu.git] / Network / HTTP / Lucu / Preprocess.hs
index c1f1a8b8dacc9c8e91cc21907f3053c3a55a7cda..5e1d095151fb16b9a59e86730af5946971317638 100644 (file)
@@ -51,7 +51,8 @@ import GHC.Conc (unsafeIOToSTM)
 
 preprocess :: Interaction -> STM ()
 preprocess itr
-    = do req <- readItr itr itrRequest fromJust
+    = itr `seq`
+      do req <- readItr itr itrRequest fromJust
 
          let reqVer = reqVersion req
 
@@ -80,14 +81,16 @@ preprocess itr
     where
       setStatus :: StatusCode -> STM ()
       setStatus status
-          = updateItr itr itrResponse
-            $ \ res -> res {
-                         resStatus = status
-                       }
+          = status `seq`
+            updateItr itr itrResponse
+            $! \ res -> res {
+                          resStatus = status
+                        }
 
       completeAuthority :: Request -> STM ()
       completeAuthority req
-          = when (uriAuthority (reqURI req) == Nothing)
+          = req `seq`
+            when (uriAuthority (reqURI req) == Nothing)
             $ if reqVersion req == HttpVersion 1 0 then
                   -- HTTP/1.0 なので Config から補完
                   do let conf = itrConfig itr
@@ -120,24 +123,27 @@ preprocess itr
 
       updateAuthority :: String -> String -> STM ()
       updateAuthority host portStr
-          = updateItr itr itrRequest
-            $ \ (Just req) -> Just req {
-                                reqURI = let uri = reqURI req
-                                         in uri {
-                                              uriAuthority = Just URIAuth {
-                                                                  uriUserInfo = ""
-                                                                , uriRegName  = host
-                                                                , uriPort     = portStr
-                                                                }
-                                            }
-                              }
+          = host `seq` portStr `seq`
+            updateItr itr itrRequest
+            $! \ (Just req) -> Just req {
+                                 reqURI = let uri = reqURI req
+                                          in uri {
+                                               uriAuthority = Just URIAuth {
+                                                                   uriUserInfo = ""
+                                                                 , uriRegName  = host
+                                                                 , uriPort     = portStr
+                                                              }
+                                             }
+                               }
                 
 
+      preprocessHeader :: Interaction -> (String, String) -> STM ()
       preprocessHeader itr (name, value)
-          = case map toLower name of
+          = itr `seq` name `seq` value `seq`
+            case map toLower name of
 
               "expect"
-                  -> if value `noCaseEq` "100-continue" then
+                  -> if value `noCaseEq'` "100-continue" then
                          writeItr itr itrExpectedContinue True
                      else
                          setStatus ExpectationFailed