Esempio n. 1
0
        void SendToTarget(Uri targetUrl, LinkbackSendParameters parameters)
        {
            HttpWebRequestAbstraction request = HttpWebRequestAbstraction.Create(targetUrl);

            SetupRequest(request, parameters);

            using (HttpWebResponseAbstraction response = request.GetResponse())
            {
                if (!response.IsHttpStatusCode2XX)
                {
                    throw new LinkbackSendException(String.Format(CultureInfo.InvariantCulture, "Http error while sending {0} for {1}", Name, targetUrl));
                }

                Stream receiveStream = response.GetResponseStream();

                if (response.ContentEncoding.ToUpperInvariant().Contains("GZIP"))
                {
                    receiveStream = new GZipStream(receiveStream, CompressionMode.Decompress);
                }
                else if (response.ContentEncoding.ToUpperInvariant().Contains("DEFLATE"))
                {
                    receiveStream = new DeflateStream(receiveStream, CompressionMode.Decompress);
                }

                StreamReader streamReader = new StreamReader(receiveStream, Encoding.UTF8);

                ParseResponse(targetUrl, streamReader.ReadToEnd());
            }
        }
Esempio n. 2
0
        protected override Uri DiscoveryTargetUrl(Uri sendUrl, LinkbackSendParameters parameters)
        {
            HttpWebRequestAbstraction request = HttpWebRequestAbstraction.Create(sendUrl);

            using (HttpWebResponseAbstraction response = request.GetResponse())
            {
                if (response.IsHttpStatusCode2XX)
                {
                    return(FindTargetUrl(sendUrl, response));
                }
            }

            throw new LinkbackSendException(String.Format(CultureInfo.InvariantCulture, "Http error while discovering {0} url for {1}", Name, sendUrl));
        }
Esempio n. 3
0
        protected string DownloadSourceContent(Uri sourceUrl)
        {
            HttpWebRequestAbstraction request = HttpWebRequestAbstraction.Create(sourceUrl);

            using (HttpWebResponseAbstraction response = request.GetResponse())
            {
                if (response.IsHttpStatusCode2XX)
                {
                    Stream       receiveStream = response.GetResponseStream();
                    StreamReader streamReader  = new StreamReader(receiveStream, Encoding.UTF8);
                    return(streamReader.ReadToEnd());
                }
            }

            throw new LinkbackReceiveException(String.Format(CultureInfo.InvariantCulture, "Http error while discovering {0} source at {1}", Name, sourceUrl));
        }