packages feed

fastcgi 3001.0.2 → 3001.0.2.1

raw patch · 7 files changed

+110/−2 lines, 7 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ examples/Makefile view
@@ -0,0 +1,14 @@+PROGS = upload.fcgi download.fcgi printinput.fcgi hello.fcgi++GHCFLAGS = -package fastcgi -fwarn-unused-imports++.PHONY: all clean++all: $(PROGS)++%.fcgi: %.hs+	ghc $(GHCFLAGS) --make -o $@ $^ ++clean:+	-rm -f *.hi *.o+	-rm -f $(PROGS)
+ examples/download.hs view
@@ -0,0 +1,18 @@+-- Takes server file path from the file parameter and sends+-- that to the client.+-- WARNING: this script is a SECURITY RISK and only for +-- demo purposes. Do not put it on a public web server.++import Network.FastCGI++form = concat ["<html><body><form>",+               "<input type='text' name='file' /><br />",+               "<input type='submit' />",+               "</form></body></html>"]++sendFile f = do setHeader "Content-type" "application/octet-stream"+                outputFile f++cgiMain = getInput "file" >>= maybe (output form) sendFile++main = runFastCGI cgiMain
+ examples/hello.hs view
@@ -0,0 +1,5 @@+import Network.FastCGI++cgiMain = output "Hello World!"++main = runFastCGI cgiMain
+ examples/printinput.hs view
@@ -0,0 +1,35 @@+-- Prints the values of all CGI variables and inputs, and some +-- process information.++import Control.Monad (liftM)+import Data.Maybe (fromJust)++import Control.Concurrent+import System.Posix.Process (getProcessID)++import Network.FastCGI++printinput :: CGI CGIResult+printinput = do setHeader "Content-type" "text/plain"+                vs <- getVars+                is <- getInputNames+                i <- mapM prInput is+                pid <- liftIO getProcessID+                threadId <- liftIO myThreadId+                let tid = concat $ drop 1 $ words $ show threadId+                output $ unlines ["Environment:", prVars vs,+	                          "Inputs:", unlines i,+	                          "Process ID: " ++ show pid,+	                          "Thread ID:  " ++ tid]++prVars vs = unlines [k ++ ": " ++ x | (k,x) <- vs ]++prInput :: String -> CGI String+prInput i = do v <- liftM fromJust (getInput i)+               f <- getInputFilename i+               return $ case f of+                          Just n -> i ++ ": File\nfilename=" ++ n+                                    ++ "\ncontents=" ++ v+                          Nothing -> i ++ ": " ++ v ++main = runFastCGIorCGI printinput
+ examples/upload.hs view
@@ -0,0 +1,32 @@+-- Accepts file uploads and saves the files in the given directory.+-- WARNING: this script is a SECURITY RISK and only for +-- demo purposes. Do not put it on a public web server.++import Control.Monad (liftM)+import Data.Maybe (fromJust)++import qualified Data.ByteString.Lazy as BS+import Network.FastCGI++dir = "upload"++cgiMain = do m <- getInputFilename "file"+             case m of +               Just n  -> saveFile n+               Nothing -> output form++saveFile n =+    do+    cont <- liftM fromJust $ getInputFPS "file"+    let p = dir ++ "/" ++ basename n+    liftIO $ BS.writeFile p cont+    output $ "Saved as <a href='" ++ p ++ "'>" ++ p ++ "</a>."++form = concat ["<html><body><form method='post' enctype='multipart/form-data'>",+               "<input type='file' name='file' /><br />",+               "<input type='submit' />",+               "</form></body></html>"]++basename = reverse . takeWhile (`notElem` "/\\") . reverse++main = runFastCGI cgiMain
+ fastcgi.buildinfo.in view
@@ -0,0 +1,3 @@+ghc-options: -optc@CPPFLAGS@+cc-options:  @CPPFLAGS@+ld-options:  @LDFLAGS@
fastcgi.cabal view
@@ -1,16 +1,17 @@ Name:           fastcgi-Version:        3001.0.2+Version:        3001.0.2.1 Copyright:      Bjorn Bringert, Lemmih Maintainer:     bjorn@bringert.net License:        BSD3 license-file:   LICENSE+Category:       Network Synopsis:       A Haskell library for writing FastCGI programs Description:  This library lets you write FastCGI programs. This package reuses the  cgi package API, making it very easy to port CGI programs to FastCGI. Cabal-version: >= 1.2.0 build-type:     Configure-extra-source-files: configure+extra-source-files: configure fastcgi.buildinfo.in  flag small_base   description: Choose the new smaller, split-up base package.