<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thank you. I’ll work through what you’ve written.<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 5 Oct 2015, at 09:21, Kostiantyn Rybnikov <<a href="mailto:k-bx@k-bx.com" class="">k-bx@k-bx.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Just few more things which might help:<div class=""><br class=""></div><div class=""><div class="">λ res ^. responseStatus</div><div class="">Status {statusCode = 200, statusMessage = "OK"}</div><div class="">λ :t res ^. responseStatus</div><div class="">res ^. responseStatus :: Status</div><div class="">λ :i Status</div><div class="">data Status</div><div class="">  = Network.HTTP.Types.Status.Status {Network.HTTP.Types.Status.statusCode :: Int,</div><div class="">                                      Network.HTTP.Types.Status.statusMessage :: Data.ByteString.Internal.ByteString}</div><div class="">        -- Defined in ‘Network.HTTP.Types.Status’</div><div class="">instance Enum Status -- Defined in ‘Network.HTTP.Types.Status’</div><div class="">instance Eq Status -- Defined in ‘Network.HTTP.Types.Status’</div><div class="">instance Ord Status -- Defined in ‘Network.HTTP.Types.Status’</div><div class="">instance Show Status -- Defined in ‘Network.HTTP.Types.Status’</div></div><div class=""><br class=""></div><div class="">You can see how to get the status, where it comes from. So you can just do "if res ^. responseStatus /= status200 then ...".</div><div class=""><br class=""></div><div class="">Cheers.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Oct 4, 2015 at 6:18 PM, Mike Houghton <span dir="ltr" class=""><<a href="mailto:mike_k_houghton@yahoo.co.uk" target="_blank" class="">mike_k_houghton@yahoo.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="">
<br class="">
Please can someone explain how,using the wreq package, I can download and save a binary file?<br class="">
Say the file is at the end of<br class="">
<a href="http://x.y.z/files/myfile.jpg" rel="noreferrer" target="_blank" class="">http://x.y.z/files/myfile.jpg</a><br class="">
<br class="">
and it is a jpeg and no authentication is needed.<br class="">
<br class="">
I just want to<br class="">
<br class="">
1. Check that the URL is syntactically correct - flag and error if not<br class="">
2. If the URL is syntactically ok then download the file using GET.<br class="">
3. Check that the response code is 200 and if so save the file<br class="">
3a. if the response code is not 200 then delegate to an  error handling function or some simple idiomatic way of error handling.<br class="">
<br class="">
<br class="">
Thanks once again.<br class="">
<br class="">
Mike<br class="">
<br class="">
_______________________________________________<br class="">
Beginners mailing list<br class="">
<a href="mailto:Beginners@haskell.org" class="">Beginners@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br class="">
</blockquote></div><br class=""></div>
_______________________________________________<br class="">Beginners mailing list<br class=""><a href="mailto:Beginners@haskell.org" class="">Beginners@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners<br class=""></div></blockquote></div><br class=""></div></body></html>