]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Httpd.hs
Added a configuration flag -fssl to enable SSL support. (default: off)
[Lucu.git] / Network / HTTP / Lucu / Httpd.hs
index 595403abd0364f1a2e70c79088d9138d38eeaf90..883a9a651f4999a893811670ebb114badc5e4bad 100644 (file)
@@ -1,5 +1,6 @@
 {-# LANGUAGE
-    UnicodeSyntax
+    CPP
+  , UnicodeSyntax
   #-}
 -- |The entry point of Lucu httpd.
 module Network.HTTP.Lucu.Httpd
@@ -20,16 +21,11 @@ import Network.HTTP.Lucu.RequestReader
 import Network.HTTP.Lucu.Resource.Tree
 import Network.HTTP.Lucu.ResponseWriter
 import Network.HTTP.Lucu.SocketLike as SL
-import System.Posix.Signals
 
 -- |This is the entry point of Lucu httpd. It listens to a socket and
 -- waits for clients. 'runHttpd' never stops by itself so the only way
 -- to stop it is to raise an exception in the thread running it.
 --
--- Note that 'runHttpd' automatically makes SIGPIPE be ignored by
--- calling @'installHandler' 'sigPIPE' 'Ignore' 'Nothing'@. This can
--- hardly cause a problem though.
---
 -- Example:
 --
 -- > {-# LANGUAGE OverloadedStrings #-}
@@ -51,10 +47,16 @@ import System.Posix.Signals
 runHttpd ∷ Config → ResTree → [FallbackHandler] → IO ()
 runHttpd cnf tree fbs
     = withSocketsDo $
-      do void $ installHandler sigPIPE Ignore Nothing
-         let launchers
+      do let launchers
                  = catMaybes
-                   [ do scnf ← cnfSSLConfig    cnf
+                   [ do addr ← cnfServerV4Addr cnf
+                        return ( launchListener =≪ listenOn AF_INET addr (cnfServerPort cnf)
+                               )
+                   , do addr ← cnfServerV6Addr cnf
+                        return ( launchListener =≪ listenOn AF_INET6 addr (cnfServerPort cnf)
+                               )
+#if defined(HAVE_SSL)
+                   , do scnf ← cnfSSLConfig    cnf
                         addr ← cnfServerV4Addr cnf
                         return ( do so ← listenOn AF_INET addr (sslServerPort scnf)
                                     launchListener (sslContext scnf, so)
@@ -64,12 +66,7 @@ runHttpd cnf tree fbs
                         return ( do so ← listenOn AF_INET6 addr (sslServerPort scnf)
                                     launchListener (sslContext scnf, so)
                                )
-                   , do addr ← cnfServerV4Addr cnf
-                        return ( launchListener =≪ listenOn AF_INET addr (cnfServerPort cnf)
-                               )
-                   , do addr ← cnfServerV6Addr cnf
-                        return ( launchListener =≪ listenOn AF_INET6 addr (cnfServerPort cnf)
-                               )
+#endif
                    ]
          sequence_ launchers
          waitForever