Beispiel #1
0
        public override void Open()
        {
            // Used to collect the device xml asynchronously

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Find(kKeyUpnpLocation));

            // Use a HTTP 1.0 client because of bug 80017 in the mono bug database
            // Use a default WebProxy to avoid proxy authentication errors
            request.Proxy            = new WebProxy();
            request.ProtocolVersion  = HttpVersion.Version10;
            request.KeepAlive        = false;
            request.Timeout          = kDeviceXmlTimeout;
            request.ReadWriteTimeout = kDeviceXmlTimeout;

            WebRequestPool.QueueJob(new JobGetResponse(OpenResponse, request));
        }
Beispiel #2
0
        public object WriteEnd(GetResponseStreamCallback aCallback)
        {
            UTF8Encoding encoding = new UTF8Encoding();

            byte[] message = encoding.GetBytes(iWriteDocument.OuterXml);

            HttpWebRequest request   = null;
            Stream         reqStream = null;

            try
            {
                request           = WebRequest.Create(iService.ControlUri.AbsoluteUri) as HttpWebRequest;
                request.KeepAlive = false;
                request.Pipelined = false;
                request.Proxy     = iService.WebProxy;

                request.Method      = "POST";
                request.ContentType = "text/xml; charset=\"utf-8\"";
                request.Headers.Add("SOAPACTION", string.Format("\"{0}#{1}\"", Upnp.ServiceTypeToString(iService.Type), iAction.Name));
                request.ContentLength    = message.Length;
                request.Timeout          = kControlInvokeTimeout;
                request.ReadWriteTimeout = kControlInvokeTimeout;

                if (aCallback == null)
                {
                    reqStream = request.GetRequestStream();
                    reqStream.Write(message, 0, message.Length);
                }
                else
                {
                    WebRequestPool.QueueJob(new JobSendRequest(aCallback, request, message));
                }
            }
            finally
            {
                if (aCallback == null && reqStream != null)
                {
                    reqStream.Close();
                    reqStream.Dispose();
                }

                iWriteDocument = null;
                iActionNode    = null;
            }

            return(request);
        }
Beispiel #3
0
 private void DownloadArtwork(Uri aAlbumArtUri)
 {
     try
     {
         HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(aAlbumArtUri);
         wreq.Proxy                     = new WebProxy();
         wreq.KeepAlive                 = false;
         wreq.Pipelined                 = false;
         wreq.ContentLength             = 0;
         wreq.AllowWriteStreamBuffering = true;
         WebRequestPool.QueueJob(new JobGetResponse(GetResponseCallback, wreq));
     }
     catch (Exception e)
     {
         Console.WriteLine("FormStatus.DownloadArtwork: " + e.Message);
     }
 }
Beispiel #4
0
        private void ProcessRequest(Artwork aArtwork)
        {
            Trace.WriteLine(Trace.kKinsky, "ArtworkCache.ProcessRequest: Downloading " + aArtwork.UriDownload);

            try
            {
                HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(aArtwork.UriDownload);
                wreq.Proxy = new WebProxy();
                wreq.KeepAlive = false;
                wreq.Pipelined = false;
                wreq.AllowWriteStreamBuffering = true;
                WebRequestPool.QueueJob(new JobGetResponse(GetResponseCallback, new WebRequestState(wreq, aArtwork)));
            }
            catch (Exception e)
            {
                DownloadError(aArtwork, e.Message);
            }
        }