Пример #1
0
 protected override void OnOutput(BitwiseStream data)
 {
     try
     {
         data.CopyTo(stream);
     }
     catch (IOException ioException)
     {
         throw new SoftException("Error, Console Output Too Large", ioException);
     }
 }
Пример #2
0
        protected override BitwiseStream internalEncode(BitwiseStream data)
        {
            BitStream ret = new BitStream();

            using (var bzip2 = new BZip2OutputStream(ret, true))
            {
                data.CopyTo(bzip2);
            }

            ret.Seek(0, SeekOrigin.Begin);
            return(ret);
        }
Пример #3
0
        protected override BitwiseStream internalEncode(BitwiseStream data)
        {
            BitStream ret = new BitStream();

            using (var strm = new GZipStream(ret, CompressionMode.Compress, true))
            {
                data.CopyTo(strm);
            }

            ret.Seek(0, SeekOrigin.Begin);
            return(ret);
        }
Пример #4
0
 protected override void OnOutput(BitwiseStream data)
 {
     try
     {
         PerformRemoting(delegate()
         {
             _stream.SetLength(0);
             data.CopyTo(_stream);
             _stream.Seek(0, SeekOrigin.Begin);
             _publisher.output(_stream);
         });
     }
     catch (System.Runtime.Remoting.RemotingException re)
     {
         logger.Warn("Ignoring remoting exception on OnOutput");
         logger.Debug(re);
     }
 }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="transform"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        protected static BitStream CryptoStream(BitwiseStream stream, ICryptoTransform transform, CryptoStreamMode mode)
        {
            BitStream ret = new BitStream();

            if (mode == CryptoStreamMode.Write)
            {
                var cs = new CryptoStream(ret, transform, mode);
                stream.CopyTo(cs);
                cs.FlushFinalBlock();
            }
            else
            {
                var cs = new CryptoStream(stream, transform, mode);
                cs.CopyTo(ret);
            }

            if (stream.Position != stream.Length)
            {
                throw new PeachException("Didn't transform all bytes.");
            }

            ret.Seek(0, SeekOrigin.Begin);
            return(ret);
        }
Пример #6
0
 protected override void OnOutput(BitwiseStream data)
 {
     data.CopyTo(stream);
 }
Пример #7
0
        private void CreateClient(BitwiseStream data)
        {
            if (Response != null)
            {
                Response.Close();
                Response = null;
            }

            // Send request with data as body.
            Uri url = new Uri(Url);

            if (!string.IsNullOrWhiteSpace(Query))
            {
                url = new Uri(Url + "?" + Query);
            }

            var request = (HttpWebRequest)HttpWebRequest.Create(url);

            request.Method = Method;

            if (Cookies)
            {
                request.CookieContainer = CookieJar;
            }

            if (credentials != null)
            {
                request.Credentials = credentials;
            }

            foreach (var header in Headers.Keys)
            {
                request.Headers[header] = Headers[header];
            }

            if (data != null)
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("\n\n" + Utilities.HexDump(data));
                }

                try
                {
                    using (var sout = request.GetRequestStream())
                    {
                        data.CopyTo(sout);
                    }
                }
                catch (ProtocolViolationException ex)
                {
                    throw new SoftException(ex);
                }
            }
            else
            {
                request.ContentLength = 0;
            }

            try
            {
                Response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException ex)
            {
                throw new SoftException(ex);
            }

            _client     = Response.GetResponseStream();
            _clientName = url.ToString();

            StartClient();
        }
Пример #8
0
 protected virtual void ClientWrite(BitwiseStream data)
 {
     data.CopyTo(_client);
 }
Пример #9
0
 protected override void OnOutput(BitwiseStream data)
 {
     data.CopyTo(stream, BitwiseStream.BlockCopySize);
 }