simonmar/parconc-examples

HTTPS for Wikipedia

nomicflux opened this issue · 1 comments

Wikipedia now seems to use HTTPS for all connections, which breaks the example code for the geturl files.

I've found that on my computer, not using a proxy or anything to complicate the connection, the following simple changes to geturl1.hs allow it to work:

import Control.Concurrent
import qualified Data.ByteString.Lazy as B     -- Use Data.ByteString.Lazy
import Network.HTTP.Conduit                         
      -- Use Network.HTTP.Conduit instead of the GetURL.hs file

main = do
  m1 <- newEmptyMVar
  m2 <- newEmptyMVar

  forkIO $ do
    r <- simpleHttp "https://www.wikipedia.org/wiki/Shovel"    -- Change getURL to simpleHttp
    putMVar m1 r

  forkIO $ do
    r <- simpleHttp "https://www.wikipedia.org/wiki/Spade"    -- Change getURL to simpleHttp
    putMVar m2 r

  r1 <- takeMVar m1
  r2 <- takeMVar m2
  print (B.length r1, B.length r2)

Thanks! 0.4.4 should fix this.