Skip to content

Instantly share code, notes, and snippets.

@ijt
Created April 29, 2011 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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