Skip to content

Instantly share code, notes, and snippets.

@ijt
Created April 29, 2011 21:33
Show Gist options
  • Save ijt/949080 to your computer and use it in GitHub Desktop.
Save ijt/949080 to your computer and use it in GitHub Desktop.
Example of an HTTP request in Haskell
#!/usr/bin/env runhaskell
import GHC.IO.Handle
import Network
import Network.Socket
main = do
handle <- connectTo "hackage.haskell.org" (PortNumber 80)
hPutStr handle "GET /packages/hackage.html HTTP/1.1\n"
hPutStr handle "Host: hackage.haskell.org\n"
hPutStr handle "\n"
hFlush handle
result <- hGetContents handle
putStrLn result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment