Version 0.0.0.4-0 of tighttp is deprecated.
The latest version of tighttp is 0.0.0.10-1.
tighttp
Version 0.0.0.4 revision 0 uploaded by YoshikuniJujo.
Package meta
- Synopsis
- Tiny and Incrementally-Growing HTTP library
- Description
Example programs
examples/get.hs
This is simple client. This send GET request and show page source. Run as following.
runhaskell get.hs hackage.haskell.org /packages/
extensions
PackageImports
import "monads-tf" Control.Monad.Trans import Data.Pipe import System.Environment import Network import Network.TigHTTP.Client import Network.TigHTTP.Types import qualified Data.ByteString as BS main :: IO () main = do addr : pth : _ <- getArgs h <- connectTo addr $ PortNumber 80 r <- request h $ get addr 80 pth _ <- runPipe $ responseBody r =$= finally printP (putStrLn "") return () printP :: MonadIO m => Pipe BS.ByteString () m () printP = await >>= maybe (return ()) (\s -> liftIO (BS.putStr s) >> printP)
examples/server.hs
This is simple server. This recieve client's request. And send command line arguments as response. Run as following.
runhaskell server.hs Hello World I Am TigHTTP
import Control.Monad import Control.Concurrent import Data.Pipe import System.IO import System.Environment import Network import Network.TigHTTP.Server import Network.TigHTTP.Types import qualified Data.ByteString.Char8 as BSC import qualified Data.ByteString.Lazy as LBS main :: IO () main = do as <- getArgs soc <- listenOn $ PortNumber 80 forever $ do (h, _, _) <- accept soc void . forkIO $ do req <- getRequest h print $ requestPath req putResponse h . (response :: LBS.ByteString -> Response Pipe Handle) . LBS.fromChunks $ map BSC.pack as
If you want more examples. Please see examples directory.
- Author
- Yoshikuni Jujo <PAF01143@nifty.ne.jp>
- Bug reports
- n/a
- Category
- Network
- Copyright
- n/a
- Homepage
- https://github.com/YoshikuniJujo/tighttp/wiki
- Maintainer
- Yoshikuni Jujo <PAF01143@nifty.ne.jp>
- Package URL
- n/a
- Stability
- Experimental