[Haskell-beginners] Get responsecode(Int) from simpleHTTP's Response

Jacques du Rand jacquesdr at gmail.com
Tue Oct 16 21:10:47 CEST 2012


HI all
I'm trying to write a function that gives me the HTTP code in Int

--This is broken
getStatusCode::Response->String
getStatusCode (Response _,x1,_,_) = x1

--this work the download  trying to get http status code as well
download_file fname url= do
let clean_uri = check_url url
putStrLn ("Downloading " ++ url ++ "...")
rsp <- simpleHTTP (defaultGETRequest_ clean_uri)
--problamatic function next line
                                                        print
(getStatusCode rsp)
file_buffer <- getResponseBody(rsp)
B.writeFile fname file_buffer
Best Regards

Jacques
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121016/f246ddf2/attachment.htm>


More information about the Beginners mailing list