Most likely you also have the zlib package (cabal-install needs it), so
let's use it. Attached therefore.hs
import qualified Data.ByteString.Lazy as LB
import Codec.Compression.GZip(decompress)
import Network.URI(parseURI)
import Network.HTTP
url = "http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne"
-- steal from getRequest but change type
-- it's lazy bytestring because the GZip library specifies it
myGetRequest :: String -> Request LB.ByteString
myGetRequest s = case parseURI s of
Nothing -> error "url syntax error"
Just uri -> mkRequest GET uri
main = do
result <- simpleHTTP (insertHeader HdrAcceptEncoding "gzip" (myGetRequest url))
case result of
Left e -> print e
Right rsp -> do
let src = case findHeader HdrContentEncoding rsp of
Nothing -> rspBody rsp
Just "gzip" -> decompress (rspBody rsp)
Just _ -> error "TODO: other decompressions"
LB.writeFile "test.html" src
LB.putStrLn src
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe