Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Created January 27, 2013 03:47
Show Gist options
  • Save markhibberd/4646166 to your computer and use it in GitHub Desktop.
Save markhibberd/4646166 to your computer and use it in GitHub Desktop.
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
main = simpleHttp "http://www.haskell.org/haskellwiki/Haskell" >>= L.putStr
[vex:tmp] 2043$ runhaskell conduit-fail.hs
conduit-fail.hs: FailedConnectionException "www.haskell.org" 80
[vex:tmp] 2044$ curl -IL http://www.haskell.org/haskellwiki/Haskell
HTTP/1.1 200 OK
Date: Sun, 27 Jan 2013 03:46:33 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch
X-Powered-By: PHP/5.2.6-1+lenny13
Content-language: en
X-Frame-Options: DENY
Vary: Accept-Encoding,Cookie
X-Vary-Options: Cookie;string-contains=wikidbUserID;string-contains=wikidb_session,Accept-Encoding;list-contains=gzip
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: private, must-revalidate, max-age=0
Last-modified: Wed, 23 Jan 2013 22:04:31 GMT
Content-Type: text/html; charset=UTF-8
@tonymorris
Copy link

Linux machine
ghc 7.4.1

$ runhaskell conduit-fail.hs | more
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <meta name="keywords" content="Haskell,Applications and libraries,Books,Foreign Function Interface,Funct
ional programming,Haskell Communities and Activities Report,Haskell in education,Haskell in industry,Haskell in research,IRC channel,Int
roduction" />

@markhibberd
Copy link
Author

Network.HTTP appears to work fine.


[vex:~] 2036$ ghci
GHCi, version 7.6.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :set prompt ">"
>:m + Network.HTTP
>simpleHTTP (getRequest "http://www.haskell.org/haskellwiki/Haskell") >>= fmap (take 100) . getResponseBody
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package bytestring-0.10.0.0 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package text-0.11.2.3 ... linking ... done.
Loading package parsec-3.1.3 ... linking ... done.
Loading package old-locale-1.0.0.5 ... linking ... done.
Loading package time-1.4.0.1 ... linking ... done.
Loading package unix-2.6.0.0 ... linking ... done.
Loading package network-2.3.1.1 ... linking ... done.
Loading package old-time-1.1.0.1 ... linking ... done.
Loading package HTTP-4000.2.4 ... linking ... done.
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtm"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment