chore: test http-conduit and basic http request

This commit is contained in:
Youwen Wu 2024-08-16 19:37:12 -07:00
parent 52a0ce91f4
commit f7e229f503
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
3 changed files with 18 additions and 4 deletions

View file

@ -23,7 +23,7 @@
(final: prev: {
suntheme = final.haskell-nix.project' {
src = ./.;
compiler-nix-name = "ghc982";
compiler-nix-name = "ghc966";
shell.tools = {
cabal = {};
hlint = {};

View file

@ -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

View file

@ -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