on master help sign in
Remove scgi
commit47003a330459f8e1b18ba87f749a9affe2bba897 authorMichael Snoyman <michael@snoyman.com> dateFri 21 Mar 2014, 14:38 (13 years ago) parent1d8fc3e
8 files changed−187
sources.txt−1 wai-handler-scgi/LICENSE−20 wai-handler-scgi/Network/Wai/Handler/SCGI.hs−96 wai-handler-scgi/README wai-handler-scgi/Setup.lhs−7 wai-handler-scgi/lighttpd.conf−19 wai-handler-scgi/test.hs−19 wai-handler-scgi/wai-handler-scgi.cabal−25
sources.txt−1
@@ -6,7 +6,6 @@
66./wai-app-static
77./wai-handler-fastcgi
88./wai-handler-launch
9−./wai-handler-scgi
109./wai-frontend-monadcgi
1110./wai-websockets
1211./wai-eventsource
wai-handler-scgi/LICENSEdeleted−20
@@ -1,20 +0,0 @@
1−Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
2−
3−Permission is hereby granted, free of charge, to any person obtaining
4−a copy of this software and associated documentation files (the
5−"Software"), to deal in the Software without restriction, including
6−without limitation the rights to use, copy, modify, merge, publish,
7−distribute, sublicense, and/or sell copies of the Software, and to
8−permit persons to whom the Software is furnished to do so, subject to
9−the following conditions:
10−
11−The above copyright notice and this permission notice shall be
12−included in all copies or substantial portions of the Software.
13−
14−THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15−EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16−MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17−NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18−LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19−OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20−WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
wai-handler-scgi/Network/Wai/Handler/SCGI.hsdeleted−96
@@ -1,96 +0,0 @@
1−{-# LANGUAGE ForeignFunctionInterface #-}
2−module Network.Wai.Handler.SCGI
3− ( run
4− , runSendfile
5− ) where
6−
7−import Network.Wai
8−import Network.Wai.Handler.CGI (runGeneric, requestBodyFunc)
9−import Foreign.Ptr
10−import Foreign.Marshal.Alloc
11−import Foreign.C
12−import Data.ByteString (ByteString)
13−import qualified Data.ByteString as S
14−import qualified Data.ByteString.Unsafe as S
15−import qualified Data.ByteString.Char8 as S8
16−import Data.IORef
17−import Data.ByteString.Lazy.Internal (defaultChunkSize)
18−
19−run :: Application -> IO ()
20−run app = runOne Nothing app >> run app
21−
22−runSendfile :: ByteString -> Application -> IO ()
23−runSendfile sf app = runOne (Just sf) app >> runSendfile sf app
24−
25−runOne :: Maybe ByteString -> Application -> IO ()
26−runOne sf app = do
27− socket <- c'accept 0 nullPtr nullPtr
28− headersBS <- readNetstring socket
29− let headers@((_, conLenS):_) = parseHeaders $ S.split 0 headersBS
30− let conLen = case reads conLenS of
31− (i, _):_ -> i
32− [] -> 0
33− conLenI <- newIORef conLen
34− runGeneric headers (requestBodyFunc $ input socket conLenI)
35− (write socket) sf app
36− drain socket conLenI
37− _ <- c'close socket
38− return ()
39−
40−write :: CInt -> S.ByteString -> IO ()
41−write socket bs = S.unsafeUseAsCStringLen bs $ \(s, l) -> do
42− _ <- c'write socket s (fromIntegral l)
43− return ()
44−
45−input :: CInt -> IORef Int -> Int -> IO (Maybe S.ByteString)
46−input socket ilen rlen = do
47− len <- readIORef ilen
48− case len of
49− 0 -> return Nothing
50− _ -> do
51− bs <- readByteString socket
52− $ minimum [defaultChunkSize, len, rlen]
53− writeIORef ilen $ len - S.length bs
54− return $ Just bs
55−
56−drain :: CInt -> IORef Int -> IO () -- FIXME do it in chunks
57−drain socket ilen = do
58− len <- readIORef ilen
59− _ <- readByteString socket len
60− return ()
61−
62−parseHeaders :: [S.ByteString] -> [(String, String)]
63−parseHeaders (x:y:z) = (S8.unpack x, S8.unpack y) : parseHeaders z
64−parseHeaders _ = []
65−
66−readNetstring :: CInt -> IO S.ByteString
67−readNetstring socket = do
68− len <- readLen 0
69− bs <- readByteString socket len
70− _ <- readByteString socket 1 -- the comma
71− return bs
72− where
73− readLen l = do
74− bs <- readByteString socket 1
75− let [c] = S8.unpack bs
76− if c == ':'
77− then return l
78− else readLen $ l * 10 + (fromEnum c - fromEnum '0')
79−
80−readByteString :: CInt -> Int -> IO S.ByteString
81−readByteString socket len = do
82− buf <- mallocBytes len
83− _ <- c'read socket buf $ fromIntegral len
84− S.unsafePackCStringFinalizer (castPtr buf) len $ free buf
85−
86−foreign import ccall unsafe "accept"
87− c'accept :: CInt -> Ptr a -> Ptr a -> IO CInt
88−
89−foreign import ccall unsafe "close"
90− c'close :: CInt -> IO CInt
91−
92−foreign import ccall unsafe "write"
93− c'write :: CInt -> Ptr CChar -> CInt -> IO CInt
94−
95−foreign import ccall unsafe "read"
96− c'read :: CInt -> Ptr CChar -> CInt -> IO CInt
wai-handler-scgi/READMEdeleted

No changes to the content.

wai-handler-scgi/Setup.lhsdeleted−7
@@ -1,7 +0,0 @@
1−#!/usr/bin/env runhaskell
2−
3−> module Main where
4−> import Distribution.Simple
5−
6−> main :: IO ()
7−> main = defaultMain
wai-handler-scgi/lighttpd.confdeleted−19
@@ -1,19 +0,0 @@
1−# Run with lighttpd -D -f lighttpd.conf
2−server.port = 3000
3−server.document-root = "."
4−server.modules = ("mod_scgi", "mod_rewrite")
5−
6−url.rewrite-once = (
7− "(.*)" => "/app/$1"
8−)
9−
10−scgi.server = (
11− "/app" => ((
12− "socket" => "/tmp/test.scgi.socket",
13− "check-local" => "disable",
14− "bin-path" => "./test",
15− "min-procs" => 1,
16− "max-procs" => 12,
17− "idle-timeout" => 30
18− ))
19−)
wai-handler-scgi/test.hsdeleted−19
@@ -1,19 +0,0 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−import Network.Wai
3−import Network.Wai.Handler.SCGI (run)
4−import qualified Data.ByteString.Lazy as L
5−import qualified Data.ByteString.Lazy.Char8 as L8
6−import qualified Data.Enumerator.List as E
7−import Network.HTTP.Types (status200)
8−
9−main = run app
10−
11−app req
12− | rawPathInfo req == "/" = return $ responseLBS status200 [("Content-Type", "text/html")] "<form method='post' action='/post'><input type='text' name='name'><input type='submit'></form>"
13−app req = do
14− bss <- E.consume
15− return $ responseLBS status200 [("Content-Type", "text/plain")] $ L.concat
16− [ L8.pack $ show $ requestHeaders req
17− , "\n"
18− , L.fromChunks bss
19− ]
wai-handler-scgi/wai-handler-scgi.cabaldeleted−25
@@ -1,25 +0,0 @@
1−name: wai-handler-scgi
2−version: 2.0.0.2
3−license: MIT
4−license-file: LICENSE
5−author: Michael Snoyman <michael@snoyman.com>
6−maintainer: Michael Snoyman <michael@snoyman.com>
7−synopsis: Wai handler to SCGI (deprecated)
8−category: Web
9−stability: stable
10−cabal-version: >= 1.6
11−build-type: Simple
12−homepage: http://www.yesodweb.com/book/web-application-interface
13−description: Moved to wai-extra
14−
15−library
16− build-depends: base >= 4 && < 5
17− , wai >= 2.0 && < 2.2
18− , wai-extra >= 2.0 && < 2.2
19− , bytestring >= 0.9.1.4
20− exposed-modules: Network.Wai.Handler.SCGI
21− ghc-options: -Wall
22−
23−source-repository head
24− type: git
25− location: git://github.com/yesodweb/wai.git