FlickrNet.Flickr.DoDownloadPicture C# (CSharp) Method

DoDownloadPicture() private method

Download a picture (or anything else actually).
private DoDownloadPicture ( string url ) : System.Stream
url string
return System.Stream
        private Stream DoDownloadPicture(string url)
        {
            HttpWebRequest req = null;
            HttpWebResponse res = null;

            try
            {
                req = (HttpWebRequest)HttpWebRequest.Create(url);
                req.UserAgent = UserAgent;
                if( Proxy != null ) req.Proxy = Proxy;
                req.Timeout = HttpTimeout;
                req.KeepAlive = false;
                res = (HttpWebResponse)req.GetResponse();
            }
            catch(WebException ex)
            {
                if( ex.Status == WebExceptionStatus.ProtocolError )
                {
                    HttpWebResponse res2 = (HttpWebResponse)ex.Response;
                    if( res2 != null )
                    {
                        throw new FlickrException((int)res2.StatusCode, res2.StatusDescription);
                    }
                }
                else if( ex.Status == WebExceptionStatus.Timeout )
                {
                    throw new FlickrException(301, "Request time-out");
                }
                throw new FlickrException(9999, "Picture download failed (" + ex.Message + ")");
            }

            return res.GetResponseStream();
        }
Flickr