From 18bd686d755bf8288ce1f2a811e7a93cc8a35928 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sat, 13 Jul 2019 09:55:35 +1200 Subject: [PATCH] Fetch webpages from the Internet. --- rhapsode.cabal | 2 +- src/Main.hs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rhapsode.cabal b/rhapsode.cabal index dd52631..3e94374 100644 --- a/rhapsode.cabal +++ b/rhapsode.cabal @@ -60,7 +60,7 @@ executable rhapsode -- other-extensions: -- Other library packages from which modules are imported. - build-depends: base >=4.9 && <4.10 + build-depends: base >=4.9 && <4.10, http-client, http-client-tls, bytestring -- Directories containing source files. hs-source-dirs: src diff --git a/src/Main.hs b/src/Main.hs index 65ae4a0..192efd4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,4 +1,17 @@ module Main where +import System.Environment + +import qualified Network.HTTP.Client as HTTP +import qualified Network.HTTP.Client.TLS as TLS +import qualified Data.ByteString.Lazy as Bytes + + main :: IO () -main = putStrLn "Hello, Haskell!" +main = do + url:_ <- getArgs + -- TODO support more URI schemes, and do nonblocking networking. This could be it's own module. + request <- HTTP.parseRequest url + manager <- HTTP.newManager TLS.tlsManagerSettings + response <- HTTP.httpLbs request manager + Bytes.putStrLn $ HTTP.responseBody response -- 2.30.2