Created
April 29, 2011 21:33
-
-
Save ijt/949080 to your computer and use it in GitHub Desktop.
Example of an HTTP request in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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