ein mensch
ein mensch

Reputation: 341

How to get data from HTTPS response using Haskell?

I use this line of Haskell code to read the content of an HTTP response:

simpleHTTP (getRequest addr) >>= getResponseBody

This line works very well for domains like http://www.example.com, but if I try something like https://www.example.com, I get an error saying that HTTPS is not supported.

How can I make the code snippet work for HTTPS?

Thank you in advance :)

PS: I don't want to install additional libraries

Upvotes: 0

Views: 407

Answers (1)

Dan Burton
Dan Burton

Reputation: 53665

It's really easy with the http-conduit package. For example:

bash> stack --resolver lts-6.7 repl http-conduit
ghci> :set -XOverloadedStrings 
ghci> import qualified Network.HTTP.Simple as H
ghci> H.getResponseBody <$> H.httpLBS "https://google.com"

https://www.stackage.org/haddock/lts-6.7/http-conduit-2.1.11/Network-HTTP-Simple.html#v:httpLBS

Upvotes: 1

Related Questions