Andriy Drozdyuk
Andriy Drozdyuk

Reputation: 61041

How can I do an HTTPS request in Haskell?

How can I do an HTTPS request in Haskell?

For example, I want to obtain a request token via HTTPS POST from Dropbox API

P.S.: I am using Windows 8

Upvotes: 28

Views: 9644

Answers (2)

unhammer
unhammer

Reputation: 4661

For less dependencies, use http-client with http-client-tls:

{-# LANGUAGE OverloadedStrings #-}

import qualified Network.HTTP.Client     as H
import qualified Network.HTTP.Client.TLS as H

main :: IO ()
main = do
  httpman <- H.newManager H.tlsManagerSettings
  let req = H.setQueryString [("q", Just "r")] "https://httpbin.org/get"
  response <- H.httpLbs req httpman
  print response

(Those packages were factored out of http-conduit; if you have no need of conduit, sticking with http-client will decrease your dependency footprint.)

Upvotes: 5

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

Thanks to packages like http-conduit, which is backed by tls, you can use simpleHttp for HTTPS.

> import Network.HTTP.Conduit
> simpleHttp "https://github.com"
...  big ugly bytestring that can be parsed in so many ways...

Upvotes: 32

Related Questions