Babra Cunningham Babra Cunningham - 7 days ago 5
HTTP Question

simpleHttp causing 'unsupported browser response?'

I'm executing a simpleHttp request to a https domain, yet the response html is showing 'unsupported browser' messages -- i believe this is because simpleHttp does not support HTTPS.

My function:

import Network.HTTP.Simple

makeRequest :: IO LAZ.ByteString
makeRequest = do
response <- simpleHttp "https://www.example.com"
return (response)


Which haskell libraries support https?

Answer

Wreq provides a very easy to follow tutorial on http/s requests using basic lens syntax.

A https compatible request is as simple as:

main = do
  r <- get "https://www.example.com"

Response statuses and bodies can be accessed respectively:

  r ^. responseStatus . statusCode
  r ^. responseBody
Comments