summaryrefslogtreecommitdiff
path: root/test.hs
blob: 3019a10b105b3c85422a5e2d4ff9d29b1df9a2b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
import Network.HTTP.Conduit
import Network
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import System.Environment.UTF8 (getArgs)
import Data.CaseInsensitive (original)
import Data.Conduit

main :: IO ()
main = withSocketsDo $ do
    [url] <- getArgs
    _req2 <- parseUrl url
    {-
    let req = urlEncodedBody
                [ ("foo", "bar")
                , ("baz%%38**.8fn", "bin")
                ] _req2
    -}
    runResourceT $ do
        man <- newManager
        Response sc hs b <- httpLbsRedirect _req2 man
#if DEBUG
        return ()
#else
        liftBase $ do
            print sc
            mapM_ (\(x, y) -> do
                S.putStr $ original x
                putStr ": "
                S.putStr y
                putStrLn "") hs
            putStrLn ""
            L.putStr b
#endif