From f7e229f50385c361e8973b120d4d4a8b31ba458d Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Fri, 16 Aug 2024 19:37:12 -0700 Subject: [PATCH] chore: test http-conduit and basic http request --- flake.nix | 2 +- newsance.cabal | 5 +++-- src/Main.hs | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 7a114ef..a341fb5 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ (final: prev: { suntheme = final.haskell-nix.project' { src = ./.; - compiler-nix-name = "ghc982"; + compiler-nix-name = "ghc966"; shell.tools = { cabal = {}; hlint = {}; diff --git a/newsance.cabal b/newsance.cabal index cda5215..59fa473 100644 --- a/newsance.cabal +++ b/newsance.cabal @@ -29,8 +29,9 @@ executable newsance hs-source-dirs: src main-is: Main.hs build-depends: - base >=4.2 && <5, - http-client ^>=0.7.17, + base ^>=4.18.2.1, + bytestring ^>=0.12.1.0, + http-conduit ^>=2.3.8.3, if flag(threaded) ghc-options: -threaded diff --git a/src/Main.hs b/src/Main.hs index d9f755b..d5fcbe8 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,3 +1,16 @@ +{-# LANGUAGE OverloadedStrings #-} + module Main (main) where -main = putStrLn "Hello, World!" +import qualified Data.ByteString.Lazy.Char8 as L8 +import Network.HTTP.Simple + +main :: IO () +main = do + response <- httpLBS "https://git.youwen.dev/youwen5/newsance.rss" + + putStrLn $ + "The status code was: " + ++ show (getResponseStatusCode response) + print $ getResponseHeader "Content-Type" response + L8.putStrLn $ getResponseBody response